package com.handinfo.game;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;

import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.rms.RecordStore;

import android.app.AlertDialog;
import android.util.Log;
import android.widget.Toast;

import cn.cmgame.billing.api.GameInterface;

import com.handinfo.engine.AbstractGameScreen;
import com.handinfo.engine.Actor;
import com.handinfo.engine.Animation;
import com.handinfo.engine.GameMIDlet;
import com.handinfo.engine.GameManager;
import com.handinfo.engine.Music;
import com.handinfo.engine.net.BaseConnection;
import com.handinfo.engine.net.GameProtocol;
import com.handinfo.engine.net.HttpConnect;
import com.handinfo.engine.resource.ObjectAdapter;
import com.handinfo.engine.resource.ResHead;
import com.handinfo.engine.resource.Resource;
import com.handinfo.engine.resource.ResourceManager;
import com.handinfo.uimenu.AbsHyperLinker;
import com.handinfo.uimenu.UIListener;
import com.handinfo.uimenu.UIManager;
import com.handinfo.uimenu.UIMessageBox;
import com.handinfo.uimenu.UIPopmenu;
import com.handinfo.uimenu.UITools;
import com.handinfo.uimenu.UIWindowFactory;
import com.handinfo.uimenu.window.UITaskWindow;
import com.handinfo.util.ArrayList;
import com.handinfo.util.Tools;
import com.test.touch.GameTouchManager;
import com.test.touch.TouchListener;
import com.test.touch.TouchRect;
import com.wb.zhanmo.R;
import com.xl.lib.Utils;

//#if edition == "JIUYOU" || edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6"
//# import com.uc.gsdk.javame.api.GameLoginHandler;
//# import com.uc.gsdk.javame.api.GameLoginListener;
//# import com.uc.gsdk.javame.api.UCSdkEvent;
//# import com.uc.gsdk.javame.api.UCSdkListener;
//#endif

public class UserScreen implements CommandListener
{
	public GameScreen gameScreen = null;
	public boolean m_in_select;
	public static byte m_record_auth;
	public byte m_port_select = 0;
	public boolean m_port = true;
	public boolean m_firsthttp = true;//首次等待创建HTTP
	public boolean m_httpconnect = false;//HTTP连接中
	public static int m_httpsuccess = 0;//HTTP 1成功 2失败
	public long m_currtime;//临时时间记录
	public HttpConnect m_http;//HTTP对象
	private String[] SERVER_LIST_IP = {
			"192.2.9.191",
			"192.2.9.191",
			"192.2.9.191",
			"192.2.9.191",
			"192.2.8.162",
			HttpConnect.HOST2,//"211.151.33.73",//211.151.33.73
			HttpConnect.HOST2,//"211.151.33.73",//211.151.33.73
			HttpConnect.HOST2,//"211.151.33.73",//211.151.33.72
			HttpConnect.HOST2,//"211.151.33.73",//211.151.33.72
			"10.10.20.30",
			HttpConnect.HOST2,//"211.151.33.73",//211.151.33.73
			HttpConnect.HOST2,//"211.151.33.73",//211.151.33.73
			"10.10.20.27"
			};
	private int[] SERVER_LIST_PORT = {
			2817,
			2819,
			8888,
			1928,
			1928,
			HttpConnect.SERVER_PORT,
			7878,
			23591,
			6666,
			7979,
			7979,
			23593,
			HttpConnect.SERVER_PORT
			};


	public static final String PACKAGE_VERSION = "0.5.0.120731";
	//#if edition == "DEBUG"
	public static final String GAME_VERSION = "1.0.2.1";//1.0.1.2
	//#else
	//# public static final String GAME_VERSION = "1.0.2.1";
	//#endif

	public static long TIME = 0;
	public static final int WAITTIME = 6000;

	public UserScreen() {
		m_user_resource = new Resource();
	}

	public UserScreen(GameScreen gameScreen)
	{
		this.gameScreen = gameScreen;
		m_user_resource = new Resource();
		initLogo();
	}

	//#if edition == "DANGLE" || edition == "JIUYOU" || edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6" || edition == "BAORUAN" || edition == "SHOUYOU" || edition == "SHOUYOU1" || edition == "SHOUYOU2" || edition == "SHOUYOU3" || edition == "TIANXIA" || edition == "JIUYOU_M" || edition == "JIUYOU_1M" || edition == "JIUYOU_2M" || edition == "JIUYOU_3M" || edition == "JIUYOU_4M"|| edition == "JIUYOU_5M" || edition == "JIUYOU_6M"
	//# private final byte[] LOGO_TIME = { 20, 20, 10 };
	//#else
	private final byte[] LOGO_TIME = {0, 20 };//, 20
	//#endif
	private void initLogo()
	{

		//#if edition == "DANGLE" || edition == "JIUYOU" || edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6" || edition == "BAORUAN" || edition == "SHOUYOU" || edition == "SHOUYOU1" || edition == "SHOUYOU2" || edition == "SHOUYOU3" || edition == "TIANXIA" || edition == "JIUYOU_M" || edition == "JIUYOU_1M" || edition == "JIUYOU_2M" || edition == "JIUYOU_3M" || edition == "JIUYOU_4M"|| edition == "JIUYOU_5M" || edition == "JIUYOU_6M"
		//# img_logo = new Image[3];
		//# img_logo[0] = Tools.createImage("/logo2.png");
		//# img_logo[1] = Tools.createImage("/logo1.png");
		//# img_logo[2] = Tools.createImage("/logo3.png");
		//#else
		img_logo = new Image[2];
//		img_logo[0] = Tools.createImage("/logo2.png");
		img_logo[1] = Tools.createImage("/logo1.png");
		//#endif
		m_logo_index = 0;
		m_logo_time = 0;
		setNextState(STATE_LOGO);
	}

	private void initImages()
	{
		img_word_list = new Image[WORD_LIST.length];
		for (int i = 0; i < img_word_list.length; i++) {
			img_word_list[i] = Tools.createImage(WORD_PATH + WORD_LIST[i] + WORD_POSTFIX);
		}
		img_background_logo = Tools.createImage("/login/beijing2.png");
		img_background = Tools.createImage("/login/beijing.png");
		img_choose_bg = Tools.createImage("/login/choose_background.png");
		img_choose_cn = Tools.createImage("/login/choose.png");
		img_select = Tools.createImage("/login/temp/w_select.png");
		img_lianhua = Tools.createImage("/login/lianhua_houmian.png");

		ResHead head = new ResHead(ObjectAdapter.RESOURCE_TYPE_ANIM, "/anim/login_lianhua.anim", 1);
		m_anim_flower = (Animation) ResourceManager.getInstance().loadResource(m_user_resource, head);
		m_actor_flower = new Actor();
		m_actor_flower.m_anims = new Animation[1];
		m_actor_flower.m_anim = m_actor_flower.m_anims[0] = m_anim_flower;
		m_actor_flower.setAction(1, true, true);

		img_small_star = Tools.createImage("/login/xiaoliangdian.png");
		img_big_star = Tools.createImage("/login/daliangdian.png");

		img_sex = Tools.createImage("/login/nannv.png");
		img_job = Tools.createImage("/login/zhiye.png");
		img_race = Tools.createImage("/login/zhongzu.png");
		img_cursor_corner = Tools.createImage("/login/guangbiao2.png");
		img_cursor_side = Tools.createImage("/login/guangbiao1.png");

		img_bar_big = Tools.createImage("/login/zhucaidananniu1.png");
		img_bar_small = Tools.createImage("/login/zhucaidananniu2.png");

		img_delete_role = Tools.createImage("/login/shanchu_xiaoheiren.png");

		//#if screen == "320240"
		//# X_ACTOR_MSG = WIDTH_SCREEN_3_1 + 80;
		//# Y_ACTOR_MSG = 50;
		//# WIDTH_ACTOR_MSG = 130;
		//# HEIGHT_ACTOR_MSG = HEIGHT_BG + Y_BG - Y_ACTOR_MSG - 10;
		//# X_CREATE_RACE = (AbstractGameScreen.SCREEN_WIDTH >> 1) + 6;// 种族
		//# X_CREATE_JOB = X_CREATE_RACE + 11;// 职业
		//# X_CREATE_SEX = X_CREATE_RACE + 14;// 性别
		//# Y_CREATE_SEX = 90;
		//# Y_CREATE_RACE = Y_CREATE_SEX - 25;
		//# Y_CREATE_JOB = Y_CREATE_SEX - 50;
		//# Y_CREATE_NAME = Y_CREATE_SEX + (img_race.getHeight() >> 1) + 6 + 10;
		//# W_CREATE_NAME = WIDTH_SCREEN_3_1;
		//# X_CREATE_NAME = WIDTH_SCREEN_4_1 * 3 - 40;// 名字
		//# X_CREATE_MSG = 10;// 信息
		//# Y_CREATE_MSG = (AbstractGameScreen.SCREEN_HEIGHT >> 1);
		//# W_CREATE_MSG = WIDTH_ACTOR_MSG;
		//# H_CREATE_MSG = Y_BG + HEIGHT_BG - Y_CREATE_MSG - 5;
		//#elif screen == "640360"
		 Y_ACTOR_MSG = Y_ACTOR_BG + 146 - 10;
		 WIDTH_ACTOR_MSG = AbstractGameScreen.SCREEN_WIDTH / 3 * 2;
		 X_ACTOR_MSG = (AbstractGameScreen.SCREEN_WIDTH - WIDTH_ACTOR_MSG) >> 1;
		 HEIGHT_ACTOR_MSG = HEIGHT_BG + Y_BG - Y_ACTOR_MSG - 10;
		 X_CREATE_RACE = (AbstractGameScreen.SCREEN_WIDTH >> 1) - 20;// 种族
		 X_CREATE_JOB = X_CREATE_RACE + 11;// 职业
		 X_CREATE_SEX = X_CREATE_RACE + 14;// 性别
		 Y_CREATE_SEX = 90;
		 Y_CREATE_RACE = Y_CREATE_SEX - 25;
		 Y_CREATE_JOB = Y_CREATE_SEX - 50;
		 Y_CREATE_NAME = Y_CREATE_SEX + (img_race.getHeight() >> 1) + 6 + 10;
		 W_CREATE_NAME = WIDTH_SCREEN_2_1;
		 X_CREATE_NAME = WIDTH_SCREEN_2_1 - WIDTH_SCREEN_4_1 + 20;// 名字
		 X_CREATE_MSG = X_ACTOR_MSG;// 信息
		 Y_CREATE_MSG = (AbstractGameScreen.SCREEN_HEIGHT >> 1) + 30;
		 W_CREATE_MSG = WIDTH_ACTOR_MSG;
		 H_CREATE_MSG = Y_BG + HEIGHT_BG - Y_CREATE_MSG - 5;
		//#else
//		X_ACTOR_MSG = (AbstractGameScreen.SCREEN_WIDTH - 170) >> 1;
//		Y_ACTOR_MSG = Y_ACTOR_BG + 146 - 10;
//		WIDTH_ACTOR_MSG = 170;
//		HEIGHT_ACTOR_MSG = HEIGHT_BG + Y_BG - Y_ACTOR_MSG - 10;
//
//		X_CREATE_RACE = m_flower_w + 6;// 种族
//		X_CREATE_JOB = X_CREATE_RACE + 11;// 职业
//		X_CREATE_SEX = X_CREATE_RACE + 14;// 性别
//
//		Y_CREATE_SEX = 90;
//		Y_CREATE_RACE = Y_CREATE_SEX - 25;
//		Y_CREATE_JOB = Y_CREATE_SEX - 50;
//
//		Y_CREATE_NAME = Y_CREATE_SEX + (img_sex.getHeight() >> 1) + 6 + 10;
//		W_CREATE_NAME = WIDTH_SCREEN_2_1;
//		X_CREATE_NAME = WIDTH_SCREEN_2_1 - WIDTH_SCREEN_4_1 + 20;// 名字
//
//		X_CREATE_MSG = X_ACTOR_MSG;// 信息
//		Y_CREATE_MSG = (AbstractGameScreen.SCREEN_HEIGHT >> 1) + 30;
//		W_CREATE_MSG = WIDTH_ACTOR_MSG;
//		H_CREATE_MSG = Y_BG + HEIGHT_BG - Y_CREATE_MSG - 5;
		//#endif

		// 女- f 男- m
		// 剑客- jk 刀客- dk 法师- fs
		// 人 - r 仙- x 妖- y 鬼- g
		// 时装 1
		m_create_role = new ActorRole(m_user_resource);

	}

	public void registerTouch(int state) {
		int[][] rect = null;
		switch (state) {
		case STATE_LOGO:
			// logoLogic();
			// break;
		case STATE_LOADING:
//			loadingLogic();
			break;
		case STATE_LOGIN_MAIN:
			GameTouchManager.registerStaticSoftKey(true, true);
			// 快速进入
			rect = new int[][]{
					{ 175, 200, 128,24 },
					{ 175, 228, 128,24 },
					{ 175, 256, 128,24 },
					};
			registerMainBtn(rect);
//			GameTouchManager.addRect(new TouchRect(new int[] { 175, 200, 128,
//					24 }, new TouchListener() {
//
//				public void doTouch(int x, int y) {
//					if (m_main_select == 0) {
//						GameTouchManager.keyPressedFire();
//					} else {
//						m_main_select = 0;
//					}
//				}
//			}));
//			GameTouchManager.addRect(new TouchRect(new int[] { 175, 228, 128,
//					24 }, new TouchListener() {
//
//				public void doTouch(int x, int y) {
//					if (m_main_select == 1) {
//						GameTouchManager.keyPressedFire();
//					} else {
//						m_main_select = 1;
//					}
//				}
//			}));
//			GameTouchManager.addRect(new TouchRect(new int[] { 175, 256, 128,
//					24 }, new TouchListener() {
//
//				public void doTouch(int x, int y) {
//					if (m_main_select == 2) {
//						GameTouchManager.keyPressedFire();
//					} else {
//						m_main_select = 2;
//					}
//				}
//			}));

//			if (m_httpconnect) {
//				httpLogic();
//			} else {
//				mainLogic();
//			}
			break;
		case STATE_LOGIN_REG:
			quickLogic();
			break;
		case STATE_LOGIN_LOGIN:
			GameTouchManager.registerStaticSoftKey(true, true);
			rect = new int[][]{
					{96,60,250,30},
					{96,90,250,30},
					//记住账号
					{173,127,112,22},
					//登录
					{124,158,72,25},

					//注册和管理
					{124,190,72,25},
					{285,190,72,25},
					//设置和帮助
					{124,224,72,25},
					{285,224,72,25},
					
					//快速注册
					{285,158,72,25},
					   //更多游戏和关于
	                   {124,258,72,25},//日本人
	                    {285,258,72,25},
					};
			registerLoginBtn(rect);
//			GameTouchManager.addRect(new TouchRect(new int[]{96,60,250,60}, new TouchListener() {
//
//				public void doTouch(int x, int y) {
//					if (m_login_select == 0) {
//						GameTouchManager.keyPressedFire();
//					} else {
//						m_login_select = 0;
//					}
//				}
//			}));
			loginLogic();
			break;
		case STATE_LOGIN_HELP:
			break;
		case STATE_LOGIN_TOPUP:
			break;
		case STATE_LOGIN_REPAIT:
			break;
		case STATE_LOGIN_SET:
			break;
		case STATE_LOGIN_ROLES:
			GameTouchManager.registerStaticSoftKey(true, true);
			rect = new int[][]{
					{149,58,55,73},
					{219,98,49,81},
					{286,58,55,73},
			};
			registerLoginRole(rect);
			roleLogic();
//			if (m_role_list[m_role_select] != null) {
//				if (!m_role_list[m_role_select].m_delete) {
//					m_actor_flower.nextFrame();
//				}
//			}
			break;
		case STATE_LOGIN_SERVER:
			GameTouchManager.registerStaticSoftKey(true, true);
			if (m_server_list != null) {
				int size = m_server_list.size();
				if (size > 0) {
					rect = new int[size][];
					for(int i=0;i<size;i++) {
						rect[i] = new int[]{10,46+i*UITools.H_SINGLE_BAR,444,UITools.H_SINGLE_BAR};
					}
				}
			}
			registerServerBtn(rect);
//			serverLogic();
			break;
		case STATE_LOGIN_CREATE:
			GameTouchManager.registerStaticSoftKey(true, true);
			rect = new int[][]{
					//职业
					{276,42,19,19},
					{300,42,19,19},
					{324,42,19,19},
					//种族
					{265,67,19,19},
					{289,67,19,19},
					{313,67,19,19},
					{337,67,19,19},
					//性别
					{279,93,19,19},
					{319,93,19,19},
					//昵称
					{144,120,249,34},
					//创建
					{206,159,70,23},
					//下框
			};
			registerCreateRole(rect);
//			createLogic();
//			if (m_create_role != null)
//				m_actor_flower.nextFrame();
			break;
		case STATE_LOGIN_BACK:
			if (!GameManager.getInstance().m_game_message.isLockNetwork()) {
				if (++m_reselect_time > 3) {
					if (GameManager.getInstance().m_scene != null) {
						ResourceManager.getInstance().removeResource(
								GameManager.getInstance().m_resource_scene,
								GameManager.getInstance().m_scene.m_resHead);
						GameManager.getInstance().m_scene = null;
					}
					initImages();
					m_role_lock = true;
					setNextState(STATE_LOGIN_ROLES);
					GameManager.getInstance().m_game_message
							.sendUserActorList();
				}
			}
			break;
		case STATE_LOGIN_EXCEPTION:
			break;
		case STATE_LOGIN_SOUND:
			GameTouchManager.registerStaticSoftKey(true, true);
//			if (!GameMIDlet.isHaveIP) {
//				if (System.currentTimeMillis() - m_currtime >= WAITTIME) {
//					GameMIDlet.isHaveIP = true;
//				}
//			} else {
//				soundLogic();
//			}
			break;
		case STATE_LOGIN_NEW_REG:
			newregLogic();
			break;
		case STATE_LOGIN_NEW_LOGIN:
			GameTouchManager.registerStaticSoftKey(true, true);
			rect = new int[][]{
					{100,60,248,31},
					{100,91,248,31},
					{192,157,99,30},
					};
			registerLoginRole(rect);
//			GameTouchManager.addRect(new TouchRect(new int[]{100,60,248,62}, new TouchListener() {
//
//				public void doTouch(int x, int y) {
//					if (m_login_select == 0) {
//						GameTouchManager.keyPressedFire();
//					} else {
//						m_login_select = 0;
//					}
//				}
//			}));
//			GameTouchManager.addRect(new TouchRect(new int[]{192,157,99,30}, new TouchListener() {
//				public void doTouch(int x, int y) {
//					if (m_login_select == 2) {
//						GameTouchManager.keyPressedFire();
//					} else {
//						m_login_select = 2;
//					}
//				}
//			}));
//			newloginLogic();
			break;
		}
	}
	void registerLoginBtn(int[][] rect) {
		if (rect == null)
			return;
		final int len = rect.length;
		for (byte i=0;i<len;i++) {
			final byte select = i;
			GameTouchManager.addStaticRect(new TouchRect(rect[i], new TouchListener() {

				public void doTouch(int x, int y) {
					if (select == len - 3) {
						if (m_auto_register_time <= 0) {
							if (GameManager.getInstance().getConnection() == null) {
								try {
									GameManager.getInstance().m_game_message.unlockNetwork();
									GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
									GameManager.getInstance().getConnection().open();
								} catch (Exception ex) {
									Tools.debug(ex);
								}
							}
							GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_READ);
							String temp;
							if ( m_httpsuccess == 0 ) {//0超时
								temp = "" + 3;
							}
							else if ( m_httpsuccess == 2) {//2失败
								temp = "" + 2;
							}
							else {
								temp = HttpConnect.NUMBER;
							}
							GameManager.getInstance().m_game_message.sendUserAutoRegister(m_user_id, HttpConnect.IMEI, HttpConnect.USERAGNET, temp);
							m_auto_register_time = 10;
						}
					} else if (select == len - 2) {//日本人
                        try {
                            GameMIDlet.s_instance.platformRequest(GameMIDlet.MORE_GAME_URL);
                        } catch (ConnectionNotFoundException e) {
                            Toast.makeText(Utils.getContext(), "联网失败，请检测网络！", Toast.LENGTH_SHORT).show();
                            e.printStackTrace();
                        }
				    } else if (select == len - 1) {
				        new AlertDialog.Builder(Utils.getContext())
				        .setTitle("关于")
				        .setMessage(R.string.app_about)
				        .setNegativeButton("返回", null)
				        .show();
                    } else {
                    	m_login_select = select;
//                        if (m_login_select == select) {
                            GameTouchManager.keyPressedFire();
//                        } else {
//
//                        }
//                        m_login_select = select;
                    }
				}
			}));
		}
	}
	void registerMainBtn(int[][] rect) {
		if (rect == null)
			return;
		int len = rect.length;
		for (int i=0;i<len;i++) {
			final int select = i;
			GameTouchManager.addStaticRect(new TouchRect(rect[i], new TouchListener() {

				public void doTouch(int x, int y) {
					if (m_main_select == select) {
						GameTouchManager.keyPressedFire();
					} else {
						m_main_select = select;
					}
				}
			}));
		}
	}

	void registerLoginRole(int[][] rect) {
		if (rect == null)
			return;
		int len = rect.length;
		for (int i=0;i<len;i++) {
			final int select = i;
			GameTouchManager.addStaticRect(new TouchRect(rect[i], new TouchListener() {

				public void doTouch(int x, int y) {
					switch(select) {
					case 0:
						GameTouchManager.keyPressedDir(2);
						break;
					case 1:
						GameTouchManager.keyPressedFire();
						break;
					case 2:
						GameTouchManager.keyPressedDir(0);
						break;
					}
				}
			}));
		}
	}
	void registerCreateRole(int[][] rect) {
		if (rect == null)
			return;
		int len = rect.length;
		for (int i=0;i<len;i++) {
			final int select = i;
			GameTouchManager.addStaticRect(new TouchRect(rect[i], new TouchListener() {

				public void doTouch(int x, int y) {
					switch(select) {
					case 0:
					case 1:
					case 2:
						m_create_select = 0;
						m_job_index = select;
						refreshCreateRoleRes();
						break;
					case 3:
					case 4:
					case 5:
					case 6:
						m_create_select = 1;
						m_race_index = select - 3;
						refreshCreateRoleRes();
						break;
					case 7:
					case 8:
						m_create_select = 2;
						m_sex_index = select - 7;
						refreshCreateRoleRes();
						break;
					case 9:
						m_create_select = 3;
						GameTouchManager.keyPressedFire();
						break;
					case 10:
						m_create_select = 4;
						GameTouchManager.keyPressedFire();
						break;
					case 11:
						m_create_select = 5;
						break;
					}
//					m_server_select = select;
//					m_server_page = 0;
//					GameTouchManager.keyPressedFire();
				}
			}));
		}
	}
	void registerServerBtn(int[][] rect) {
		if (rect == null)
			return;
		int len = rect.length;
		for (byte i=0;i<len;i++) {
			final byte select = i;
			GameTouchManager.addStaticRect(new TouchRect(rect[i], new TouchListener() {

				public void doTouch(int x, int y) {
					m_server_select = select;
					m_server_page = 0;
					GameTouchManager.keyPressedFire();
				}
			}));
		}
	}

	void registerAccountBtn(int[][] rect,final UIPopmenu pop) {
		if (rect == null)
			return;
		int len = rect.length;
		for (byte i=0;i<len;i++) {
			final byte select = i;
			GameTouchManager.addStaticRect(new TouchRect(rect[i], new TouchListener() {

				public void doTouch(int x, int y) {
					if (select < 4) {
						pop.setStopMenu(select);
						GameTouchManager.keyPressedFire();
					} else {
						GameTouchManager.keyPressedRSoft();
					}
				}
			}));
		}
	}
	void registerHelpBtn(int[][] rect,final UIPopmenu pop) {
		if (rect == null)
			return;
		int len = rect.length;
		for (byte i=0;i<len;i++) {
			final byte select = i;
			GameTouchManager.addStaticRect(new TouchRect(rect[i], new TouchListener() {

				public void doTouch(int x, int y) {
					if (select < 2) {
						pop.setStopMenu(select);
						GameTouchManager.keyPressedFire();

					} else {
						GameTouchManager.keyPressedRSoft();
					}
				}
			}));
		}
	}

	void registerRoleOperate(boolean delete) {
		int size = delete?2:3;
		int[][] rect = new int[size][];
		for (byte i=0;i<size;i++) {
			final byte select = i;
			rect[i] = new int[]{204,124+i*23,68,23};
			GameTouchManager.addStaticRect(new TouchRect(rect[i], new TouchListener() {

				public void doTouch(int x, int y) {
					m_role_menu_select = select;
					GameTouchManager.keyPressedFire();

				}
			}));
		}
	}

	public void logic()
	{
		if (GameManager.s_isControlledByUi) {// 由UiManger控制按键事件
			UIManager.getInstance().logic();
		}
		else {
			if (m_hintTimer > 0) {
				m_hintTimer--;
				// return;
			}
			if (m_next_user_state >= 0) {
				m_user_state = m_next_user_state;
				registerTouch(m_user_state);
				Tools.debugPrintln("m_user_state="+m_user_state);
				m_next_user_state = -1;
			}
			if (m_user_state >= 0) {
				if ((m_timer & 0x1F) == 0) {
					m_star_list.addElement(new Star());
				}
				if (m_star_list != null) {
					for (int i = 0; i < m_star_list.size(); i++) {
						Star star = (Star) m_star_list.elementAt(i);
						if (star.logic()) {
							star = null;
							m_star_list.removeElementAt(i);
						}
					}
				}
			}

			switch (m_user_state) {
				case STATE_LOGO:
//					logoLogic();
//					break;
				case STATE_LOADING:
					loadingLogic();
					break;
				case STATE_LOGIN_MAIN:
					if ( m_httpconnect ) {
						httpLogic();
					}else {
						mainLogic();
					}
					break;
				case STATE_LOGIN_REG:
					quickLogic();
					break;
				case STATE_LOGIN_LOGIN:
					loginLogic();
					break;
				case STATE_LOGIN_HELP:
					break;
				case STATE_LOGIN_TOPUP:
					break;
				case STATE_LOGIN_REPAIT:
					break;
				case STATE_LOGIN_SET:
					break;
				case STATE_LOGIN_ROLES:
					roleLogic();
					if (m_role_list[m_role_select] != null){
						if (!m_role_list[m_role_select].m_delete) {
							m_actor_flower.nextFrame();
						}
					}
					break;
				case STATE_LOGIN_SERVER:
					serverLogic();
					break;
				case STATE_LOGIN_CREATE:
					createLogic();
					if (m_create_role != null)
						m_actor_flower.nextFrame();
					break;
				case STATE_LOGIN_BACK:
					if (!GameManager.getInstance().m_game_message.isLockNetwork()) {
						if (++m_reselect_time > 3) {
							if (GameManager.getInstance().m_scene != null) {
								ResourceManager.getInstance().removeResource(GameManager.getInstance().m_resource_scene,
										GameManager.getInstance().m_scene.m_resHead);
								GameManager.getInstance().m_scene = null;
							}
							initImages();
							m_role_lock = true;
							setNextState(STATE_LOGIN_ROLES);
							GameManager.getInstance().m_game_message.sendUserActorList();
						}
					}
					break;
				case STATE_LOGIN_EXCEPTION:
					break;
				case STATE_LOGIN_SOUND:
					if( !GameMIDlet.isHaveIP ){
					    if( System.currentTimeMillis() - m_currtime >= WAITTIME ){
					    	GameMIDlet.isHaveIP = true;
					    }
					}else{
						soundLogic();
					}
					break;
				case STATE_LOGIN_NEW_REG:
					newregLogic();
					break;
				case STATE_LOGIN_NEW_LOGIN:
					newloginLogic();
					break;
			}
			if (++m_timer > 100000) {
				m_timer = 0;
			}
		}
	}

	public void logicAnims(){
		synchronized (m_role_list) {
			if( m_role_list != null ){
				int size = m_role_list.length;
				for(int i=0;i<size;i++){
					if( m_role_list[i] != null && m_role_list[i].m_refsResHead != null){
						ResHead[] resHead = m_role_list[i].m_refsResHead;
						Animation[] anims =  m_role_list[i].m_anims;
						//判断时装
						if( resHead[0] != null){
							if( anims[0] == null ){
								Animation anim = (Animation) ResourceManager.getInstance().loadResource(m_user_resource, resHead[0]);
								if( anim != null && anim.m_loadFinished ){
									m_role_list[i].m_anims[0] = anim;
									m_role_list[i].m_anim = m_role_list[i].m_anims[0];
									m_role_list[i].setActionFrame(2, 0);
								}
							}else{
								if( !anims[0].m_resHead.equals(resHead[0])){
									Animation anim =  (Animation) ResourceManager.getInstance().loadResource(m_user_resource, resHead[0]);
									if( anim != null && anim.m_loadFinished ){
										m_role_list[i].m_anims[0] = anim;
										m_role_list[i].m_anim = m_role_list[i].m_anims[0];
										m_role_list[i].setActionFrame(2, 0);
									}
								}
							}
						}
						//判断武器
						if( resHead[1] != null){//有武器
							if( anims[1] == null ){
								Animation anim =  (Animation) ResourceManager.getInstance().loadResource(m_user_resource, resHead[1]);
								if( anim != null && anim.m_loadFinished ){
									m_role_list[i].m_anims[1] = anim;
									m_role_list[i].setActionFrame(2, 0);
								}
							}
						}
					}
				}
			}
		}
	}

	public int m_reselect_time = 0;
	private void newloginLogic() {
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			m_login_select = --m_login_select < 0 ? 2 : m_login_select;
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			m_login_select = ++m_login_select > 2 ? 0 : m_login_select;
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			setNextState(STATE_LOGIN_MAIN);
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			switch (m_login_select) {
				case 0:
				case 1:
					form.deleteAll();
					stringItem.setText("");
					stringItem.setLabel("");

					register_name.setString(m_login_name == null ? "" : m_login_name);
					register_name.setLabel("账号 : ");

					register_password1.setString(m_login_password == null ? "" : m_login_password);
					register_password1.setLabel("密码 : ");

					form.append(register_name);
					form.append(register_password1);
					form.append(stringItem);
					form.addCommand(ok);
					form.addCommand(back);
					form.setCommandListener(this);
					form.setFormButtons();
					Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
					break;
				case 2:
					if (GameManager.getInstance().getConnection() == null) {
						try {
							GameManager.getInstance().m_game_message.unlockNetwork();
							GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
							GameManager.getInstance().getConnection().open();
						}
						catch (Exception ex) {
							Tools.debug(ex);
						}
					}
					GameManager.getInstance().m_game_message.sendUserAuth(m_login_name, m_login_password, GAME_VERSION, m_user_id);
					break;
			}
		}
	}

	private void newregLogic() {
	}
	private int m_sound_time = 0;//声音倒计时
	private int SOUND_TIMER = 5 * GameManager.FRAME_PER_SECOND;
	private void soundLogic() {
//		if (Tools.DEBUG) {
//			if (!m_port) {
//				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
//					m_port_select = --m_port_select < 0 ? (byte) (SERVER_LIST_IP.length - 1) : m_port_select;
//				}
//				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
//					m_port_select = ++m_port_select > (byte) (SERVER_LIST_IP.length - 1) ? 0 : m_port_select;
//				}
//				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
//						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
//					GameManager.SERVER_URL = SERVER_LIST_IP[m_port_select];
//					GameManager.SERVER_PORT = SERVER_LIST_PORT[m_port_select];
//					m_port = true;
//				}
//				return;
//			}
//		}
        GameManager.s_system_infos[GameManager.SET_SYSTEM_SOUND] = (byte)(GameInterface.isMusicEnabled()?1:0);//0关 1开
        Music.getInstance().setCurBackGroundId(Music.BG_MUSIC_COVER);
        GameManager.getInstance().changeSetSystem(GameManager.SET_SYSTEM_SOUND,true,false);
        exitSoundState();
//		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
//				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
//			//开启
//			GameManager.s_system_infos[GameManager.SET_SYSTEM_SOUND] = 1;//0关 1开
//			Music.getInstance().setCurBackGroundId(Music.BG_MUSIC_COVER);
//			GameManager.getInstance().changeSetSystem(GameManager.SET_SYSTEM_SOUND,true,false);
//			exitSoundState();
//		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
//			//关闭
//			GameManager.s_system_infos[GameManager.SET_SYSTEM_SOUND] = 0;//0关 1开
//			Music.getInstance().setCurBackGroundId(Music.BG_MUSIC_COVER);
//			GameManager.getInstance().changeSetSystem(GameManager.SET_SYSTEM_SOUND,true,false);
//			exitSoundState();
//		} else {
//			if (++m_sound_time > SOUND_TIMER) {
//				GameManager.s_system_infos[GameManager.SET_SYSTEM_SOUND] = 0;//0关 1开
//				Music.getInstance().setCurBackGroundId(Music.BG_MUSIC_COVER);
//				GameManager.getInstance().changeSetSystem(GameManager.SET_SYSTEM_SOUND,true,false);
//				exitSoundState();
//			}
//		}
	}

	//#if edition == "JIUYOU" || edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6"
	//# private boolean is_uc = true;
	//# private void goJiuYou() {
	//# 	GameManager.getInstance().m_pause_run = true;
	//# 	GameManager.getInstance().m_uc_sdk.login(
	//# 		new UCSdkListener() {
	//# 			public void onApiFinished(UCSdkEvent evt) {
	//# 				if (evt.success) {
	//# 					GameManager.getInstance().m_uc_sid = GameManager.getInstance().m_uc_sdk.getSid();
	//# 					Tools.debugPrintln("UC SID = " + GameManager.getInstance().m_uc_sid);
	//# 					GameManager.getInstance().m_pause_run = false;
	//# 					m_role_lock = true;
	//#						is_uc = true;
	//# 					setNextState(STATE_LOGIN_ROLES);
	//# 					GameManager.getInstance().m_uc_msg = "登录成功!";
	//# 					Tools.debugPrintln("UC登录成功!");
	//# 					return;
	//# 				}
	//# 				GameManager.getInstance().m_pause_run = false;
	//# 				GameManager.getInstance().m_uc_msg = evt.msg;
	//#					GameManager.getInstance().m_test_running = false;
	//#					GameManager.s_isRunning = false;
	//#					GameMIDlet.s_isJumpWap = true;
	//# 				Tools.debugPrintln("UC登录失败!" + GameManager.getInstance().m_uc_msg);
	//# 			}
	//# 		},true,new GameLoginHandler() {
	//# 			public void verifyGameUser(String name, String password, GameLoginListener lis) {
	//#
	//# 			}
	//# 		}
	//# 	);
	//# }
	//#endif

//	 private boolean is_uc = true;
//	 private void goJiuYou() {
//	 	GameManager.getInstance().m_pause_run = true;
//	 	GameManager.getInstance().m_uc_sdk.login(
//	 		new UCSdkListener() {
//	 			public void onApiFinished(UCSdkEvent evt) {
//	 				if (evt.success) {
//	 					GameManager.getInstance().m_uc_sid = GameManager.getInstance().m_uc_sdk.getSid();
//	 					Tools.debugPrintln("UC SID = " + GameManager.getInstance().m_uc_sid);
//	 					GameManager.getInstance().m_pause_run = false;
//	 					m_role_lock = true;
//							is_uc = true;
//	 					setNextState(STATE_LOGIN_ROLES);
//	 					GameManager.getInstance().m_uc_msg = "登录成功!";
//	 					Tools.debugPrintln("UC登录成功!");
//	 					return;
//	 				}
//	 				GameManager.getInstance().m_pause_run = false;
//	 				GameManager.getInstance().m_uc_msg = evt.msg;
//						GameManager.getInstance().m_test_running = false;
//						GameManager.s_isRunning = false;
//						GameMIDlet.s_isJumpWap = true;
//					Tools.debugPrintln("UC登录失败!" + GameManager.getInstance().m_uc_msg);
//	 			}
//	 		},true,new GameLoginHandler() {
//	 			public void verifyGameUser(String name, String password, GameLoginListener lis) {
//
//	 			}
//	 		}
//	 	);
//	 }
	private void exitSoundState() {

//		goJiuYou();
		//#if edition == "JIUYOU" || edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6"
	    //# goJiuYou();
		//#else
//		if (
				GameManager.canLoadUserRMSData(0);
//				) {
			m_login_select = LOGIN_INDEX_DLYX;
			setNextState(STATE_LOGIN_LOGIN);
//		} else {
//			setNextState(STATE_LOGIN_MAIN);
//			m_currtime = System.currentTimeMillis();
//			Tools.debugPrintln("m_currtime="+m_currtime);
//		}
		//#endif
	}

	public void releaseHttp(){
	    if( m_http != null ){
	    	m_httpconnect = false;
	    	m_http.dipose();
	    	m_http = null;
	    }
	}

	private void httpLogic()
	{
		if (m_firsthttp) {
			if (System.currentTimeMillis() - m_currtime >= 200) {
				Tools.debugPrintln("HTTP------------------------------>");
				m_http = new HttpConnect(true);
				m_http.SetState(m_http.CM_GETTELNUMBER);
				new Thread(m_http).start();
				m_currtime = System.currentTimeMillis();
				m_firsthttp = false;
			}
		}
		else {
			if ( m_httpsuccess == 0 && System.currentTimeMillis() - m_currtime >= 10000) {
				m_httpconnect = false;
			}else {
				if ( m_httpsuccess == 1) {//连接成功
//					if( HttpConnect.state == m_http.CM_GETSERVERLIST ){
//						if( m_http.url != null && m_http.url.length >= 3 ){
//							SERVER_LIST_IP[0] = m_http.url[1];
//							SERVER_LIST_PORT[0] = Integer.parseInt(m_http.url[2].trim());
//						}
//					}
					releaseHttp();
				}
				else if ( m_httpsuccess == 2 ) {//连接失败
					releaseHttp();
				}
			}
		}
	}

	private byte m_time = 0;

	public void loadingLogic()
	{

		//#if edition == "JIUYOU"|| edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6"
		//# if (m_time > 3 && GameManager.getInstance().m_uc_inited) {
		//#else
		if (m_time > 3) {
		//#endif
			if (GameManager.getInstance().m_scene != null) {
				if (GameManager.getInstance().m_role != null) {
					((GameScene) (GameManager.getInstance().m_scene)).removeRoleByID(GameManager.getInstance().m_role.m_gameID);
				}
				if (GameManager.getInstance().m_resource_scene != null && GameManager.getInstance().m_scene.m_resHead != null) {
					ResourceManager.getInstance().removeResource(GameManager.getInstance().m_resource_scene,
							GameManager.getInstance().m_scene.m_resHead);
				}
				GameManager.getInstance().m_scene = null;
			}

			GameManager.initUserRMSData();
			GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_READ);

			m_sound_time = 0;
			UIManager.createInstance();
			UIManager.createColors();
			UIManager.createImages();
			UITools.initImage();
			initImages();
			GameScene.initStaticResource();
			GameManager.getInstance().initSystemInfos();
			setNextState(STATE_LOGIN_SOUND);
			m_currtime = System.currentTimeMillis();
		}
		m_time++;
	}

	/**
	 * 创建人物界面逻辑
	 */
	private void createLogic()
	{
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (m_create_select == INDEX_CREATE_MSG) {
				if (m_create_msg_index == 0) {
					m_create_select = --m_create_select < 0 ? INDEX_CREATE_COUNT - 1 : m_create_select;
				}
				else {
					m_create_msg_index--;
				}
			}
			else {
				m_create_select = --m_create_select < 0 ? INDEX_CREATE_COUNT - 1 : m_create_select;
				refreshCreateRoleRes();
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (m_create_select == INDEX_CREATE_MSG) {
				int len = (H_CREATE_MSG - 8) / UITools.H_SINGLE_BAR;
				if (len >= m_create_msg.length || m_create_msg_index == m_create_msg.length - len) {
					m_create_select = ++m_create_select >= INDEX_CREATE_COUNT ? 0 : m_create_select;
				}
				else {
					m_create_msg_index++;
				}
			}
			else {
				m_create_select = ++m_create_select >= INDEX_CREATE_COUNT ? 0 : m_create_select;
				refreshCreateRoleRes();
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			if (m_create_select == INDEX_CREATE_CREATE && m_role_name != null && !m_role_name.equals("")) {
				GameManager.getInstance().m_game_message.sendUserCreateRole(
						m_role_name, (byte) (m_sex_index + 1), (byte) (m_job_index + 1), (byte) (m_race_index + 1));
			}
			else if (m_create_select == INDEX_CREATE_NAME) {
				form.deleteAll();
				register_name.setString("");
				stringItem.setText("");
				stringItem.setLabel("");
				register_name.setLabel("昵称 : ");
				form.append(register_name);
				form.append(stringItem);
				form.addCommand(ok);
				form.addCommand(back);
				form.setCommandListener(this);
				form.setFormButtons();
				Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			setNextState(STATE_LOGIN_ROLES);
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			if (m_create_select == INDEX_CREATE_SEX) {
				m_sex_index = --m_sex_index < 0 ? CREATE_SEX_AMOUNT - 1 : m_sex_index;
				refreshCreateRoleRes();
			}
			else if (m_create_select == INDEX_CREATE_JOB) {
				m_job_index = --m_job_index < 0 ? CREATE_JOB_AMOUNT - 1 : m_job_index;
				refreshCreateRoleRes();
			}
			else if (m_create_select == INDEX_CREATE_RACE) {
				m_race_index = --m_race_index < 0 ? CREATE_RECE_AMOUNT - 1 : m_race_index;
				refreshCreateRoleRes();
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			if (m_create_select == INDEX_CREATE_SEX) {
				m_sex_index = ++m_sex_index >= CREATE_SEX_AMOUNT ? 0 : m_sex_index;
				refreshCreateRoleRes();
			}
			else if (m_create_select == INDEX_CREATE_JOB) {
				m_job_index = ++m_job_index >= CREATE_JOB_AMOUNT ? 0 : m_job_index;
				refreshCreateRoleRes();
			}
			else if (m_create_select == INDEX_CREATE_RACE) {
				m_race_index = ++m_race_index >= CREATE_RECE_AMOUNT ? 0 : m_race_index;
				refreshCreateRoleRes();
			}

		}
	}

	private void refreshCreateRoleRes()
	{
		String url = CREATE_RES_SEX[m_sex_index] + CREATE_RES_RACE[m_race_index] + CREATE_RES_JOB[m_job_index]
				+ CREATE_RES_FASHION[0];
		if (m_create_role != null) {
			m_create_role.dispose();
			m_create_role = null;
		}
		m_create_role = new ActorRole(m_user_resource);
		m_create_role.m_posX = 120;
		m_create_role.m_posY = 150;

		initRoleRes(m_create_role, url, null);

		m_create_msg = null;
		String[] texts = UITools.splitString(CREATE_ROLE_MSG, W_CREATE_MSG - 10);
		m_create_msg = new String[texts.length + 4];
		m_create_msg[0] = "名字 : " + m_role_name;
		m_create_msg[1] = "性别 : " + CREATE_SEX[m_sex_index];
		m_create_msg[2] = "职业 : " + CREATE_JOB[m_job_index];
		m_create_msg[3] = "种族 : " + CREATE_RACE[m_race_index];
		for (int i = 0; i < texts.length; i++) {
			m_create_msg[4 + i] = texts[i];
		}
		m_create_msg_index = 0;
	}

	/**
	 * 服务器列表界面逻辑
	 */
	private void serverLogic()
	{
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			if (m_server_list != null) {
				byte[] result = UITools.keyPressedIndexPage(m_server_select, m_server_page, m_server_list.size(), AMOUNT_SERVER_BOX, UITools.OPERATION_MINUS);
				m_server_select = result[UITools.KPIP_INDEX];
				m_server_page = result[UITools.KPIP_PAGE];
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			if (m_server_list != null) {
				byte[] result = UITools.keyPressedIndexPage(m_server_select, m_server_page, m_server_list.size(), AMOUNT_SERVER_BOX, UITools.OPERATION_ADD);
				m_server_select = result[UITools.KPIP_INDEX];
				m_server_page = result[UITools.KPIP_PAGE];
			}
		}
		else if ( AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)){
			GameManager.getInstance().closeConnection();
			GameManager.getInstance().clearConnection();
			m_login_select = 0;
			m_role_menu_select = 0;
			m_role_menu = false;
			m_role_select = 0;
			m_in_select = false;
			//#if edition == "JIUYOU"|| edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6"
			//# goJiuYou();
			//# setNextState(STATE_LOGIN_SOUND);
			//#else
			setNextState(STATE_LOGIN_LOGIN);
			//#endif
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {

			if( !m_in_select){
				return;
			}
			m_in_select = false;
//			if (GameManager.getInstance().getConnection() != null) {
//				GameManager.getInstance().closeConnection();
//			}
//			Function func = (Function) m_server_list.elementAt(m_server_select);
//			GameManager.getInstance().m_server_name = func.m_name;
//			try {
//				Tools.debugPrintln("重新链接 : " + func.m_ip + " : " + func.m_port);
//				GameManager.getInstance().createConnection(func.m_ip, func.m_port);
//				GameManager.getInstance().getConnection().open();
//			}
//			catch (Exception ex) {
//				Tools.debug(ex);
//			}
			GameManager.getInstance().m_game_message.sendUserReauth(m_login_name, m_server_session);
		}
		// Tools.debugPrintln("m_serverSelect = " + m_serverSelect);
	}

	/**
	 * 人物列表界面逻辑
	 */
	private void roleLogic()
	{
		if (!m_role_lock) {
			if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
				if (!m_role_menu) {
					if (!m_trigger) {
						m_trigger = true;
						m_trigger_dir = false;
					}
				}
			}
			else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
				if (!m_role_menu) {
					if (!m_trigger) {
						m_trigger = true;
						m_trigger_dir = true;
					}
				}
			}
			else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
				if (!m_trigger) {
					if (m_role_menu) {
						if (m_role_list[m_role_select].m_delete) {
							m_role_menu_select = --m_role_menu_select < 0 ? 1 : m_role_menu_select;
						}
						else {
							m_role_menu_select = --m_role_menu_select < 0 ? 2 : m_role_menu_select;
						}
					}
				}
			}
			else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
				if (!m_trigger) {
					if (m_role_menu) {
						if (m_role_list[m_role_select].m_delete) {
							m_role_menu_select = ++m_role_menu_select > 1 ? 0 : m_role_menu_select;
						}
						else {
							m_role_menu_select = ++m_role_menu_select > 2 ? 0 : m_role_menu_select;
						}
					}
				}
			}
			else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
				if (m_role_menu) {
					m_role_menu = false;
				}
				else {
					GameManager.getInstance().m_game_message.sendUserServerList();
//					GameManager.getInstance().closeConnection();
//					GameManager.getInstance().clearConnection();
//					m_login_select = 0;
//					m_role_menu_select = 0;
//					m_role_menu = false;
//					m_role_select = 0;
//
//					//#if edition == "JIUYOU"|| edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6"
//					//# goJiuYou();
//					//# setNextState(STATE_LOGIN_SOUND);
//					//#else
//					setNextState(STATE_LOGIN_LOGIN);
//					//#endif
				}
			}
			else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
					|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
				if (!m_trigger) {
					if (m_role_menu) {
						if (m_role_list[m_role_select] != null) {
							if (m_role_list[m_role_select].m_delete) {
								switch (m_role_menu_select) {
									case 0:// 找回角色
										GameManager.getInstance().m_game_message.sendUserFindRole(m_role_list[m_role_select].m_gameID);
										break;
									case 1:// 返回
										m_role_menu_select = 0;
										m_role_menu = false;
										break;
								}
							} else {
								switch (m_role_menu_select) {
									case 0:// 进入
										GameManager.getInstance().m_game_message.sendUserSelectRole(m_role_list[m_role_select].m_gameID);
										break;
									case 1:// 删除
										GameManager.getInstance().m_game_message.sendUserDeleteRole(m_role_list[m_role_select].m_gameID);
										break;
									case 2:// 返回
										m_role_menu_select = 0;
										m_role_menu = false;
										break;
								}
							}
							GameTouchManager.recoverRect();
						}
					}
					else {
						if (m_role_list[m_role_select] != null) {
							GameTouchManager.backUpRect();
							GameTouchManager.registerStaticSoftKey(true, true);
							registerRoleOperate(m_role_list[m_role_select].m_delete);
							m_role_menu = true;
							m_role_menu_select = 0;
						} else {
							m_sex_index = Tools.getRandom(0, CREATE_SEX_AMOUNT - 1);
							m_race_index = Tools.getRandom(0, CREATE_RECE_AMOUNT - 1);
							m_job_index = Tools.getRandom(0, CREATE_JOB_AMOUNT - 1);
							m_create_select = INDEX_CREATE_NAME;
							m_role_name = "";
							refreshCreateRoleRes();
							setNextState(STATE_LOGIN_CREATE);
						}
					}
				}
			}
			else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_B)) {
//				GameManager.getInstance().m_game_message.sendUserServerList();
			}
			if (m_trigger) {
				if (m_trigger_dir) {// 右
					m_angle_create -= 360 / 3 / 4;
					if (-m_angle_create % (360 / 3) == 0) {
						m_trigger = false;
						m_role_select = ++m_role_select >= ROLE_LIST_SIZE ? 0 : m_role_select;
					}
				}
				else {// 左
					m_angle_create += 360 / 3 / 4;
					if (m_angle_create % (360 / 3) == 0) {
						m_trigger = false;
						m_role_select = --m_role_select < 0 ? ROLE_LIST_SIZE - 1 : m_role_select;
					}
				}
			}
		} else {
			//#if edition == "JIUYOU"|| edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6"
			//#	if (is_uc) {
			//#	if (GameManager.getInstance().getConnection() == null) {
			//#		try {
			//#			GameManager.getInstance().m_game_message.unlockNetwork();
			//#			GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
			//#			GameManager.getInstance().getConnection().open();
			//#		}catch (Exception ex) {
			//#			Tools.debug(ex);
			//#		}
			//#	}
			//#	GameManager.getInstance().m_game_message.sendUserAuth("uc", GameManager.getInstance().m_uc_sid, GAME_VERSION, m_user_id);
			//#	is_uc = false;
			//# }
			//#endif
		}
	}

	/**
	 * logo逻辑
	 */
	private void logoLogic()
	{
		if (m_logo_time <= 0) {
			if (m_logo_index < LOGO_TIME.length) {
				m_logo_time = LOGO_TIME[m_logo_index];
				m_logo_index++;
			}
			else {
				setNextState(STATE_LOADING);
			}
		}
		else {
			m_logo_time--;
		}
	}

	/**
	 * 用户中心主界面逻辑
	 */
	private void mainLogic()
	{
		if (m_if_game) {
			return;
		}
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
//			if (!m_trigger) {
//				m_trigger = true;
//				m_trigger_dir = false;
//			}
			 m_main_select = --m_main_select < 0 ? INDEX_LOGIN_COUNT - 1 : m_main_select;
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
//			if (!m_trigger) {
//				m_trigger = true;
//				m_trigger_dir = true;
//			}
			 m_main_select = ++m_main_select >= INDEX_LOGIN_COUNT ? 0 : m_main_select;
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			if (!m_trigger) {
				switch (m_main_select) {
					case INDEX_LOGIN_ZHZC:
						form.deleteAll();
						register_name.setString("");
						register_name.setLabel("账号 : ");
						register_password1.setString("");
						register_password1.setLabel("密码 : ");
						register_password2.setString("");
						register_password2.setLabel("确认密码 : ");
						stringItem.setText("");
						stringItem.setLabel("");
						form.append(register_name);
						form.append(register_password1);
						form.append(register_password2);
						form.append(stringItem);
						form.addCommand(ok);
						form.addCommand(back);
						form.setCommandListener(this);
						form.setFormButtons();
						Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
						break;
					case INDEX_LOGIN_DLYX:
						setNextState(STATE_LOGIN_NEW_LOGIN);
						break;
					case INDEX_LOGIN_KSZC:
						if (m_auto_register_time <= 0) {
							if (GameManager.getInstance().getConnection() == null) {
								try {
									GameManager.getInstance().m_game_message.unlockNetwork();
									GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
									GameManager.getInstance().getConnection().open();
								} catch (Exception ex) {
									Tools.debug(ex);
								}
							}
							GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_READ);
							String temp;
							if ( m_httpsuccess == 0 ) {//0超时
								temp = "" + 3;
							}
							else if ( m_httpsuccess == 2) {//2失败
								temp = "" + 2;
							}
							else {
								temp = HttpConnect.NUMBER;
							}
							GameManager.getInstance().m_game_message.sendUserAutoRegister(m_user_id, HttpConnect.IMEI, HttpConnect.USERAGNET, temp);
							m_auto_register_time = 10;
						}
//						GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, "暂不接受注册");
						break;
//					case INDEX_LOGIN_BZGY:
//						// setNextState(STATE_LOGIN_HELP);
//						break;
//					case INDEX_LOGIN_YXSZ:
//						// setNextState(STATE_LOGIN_SET);
//						break;
//					case INDEX_LOGIN_ZHCZ:
//					case INDEX_LOGIN_XFYX:
//						break;
//					case INDEX_LOGIN_TCYX:
//						exitGame();
//						break;
				}
			}
		}
		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			// if (m_loginName != null && m_loginPassword != null) {
			// GameManager.getInstance().m_gameMessage.sendREG(m_loginName,
			// m_loginPassword);
			// }
			exitGame();
		}
		if (m_auto_register_time > 0) {
			m_auto_register_time--;
		}
//		if (m_trigger) {
//			if (m_trigger_dir) {// 右
//				m_angle_login -= 360 / MAIN_MENU_AMOUNT / 3;
//				if (-m_angle_login % (360 / MAIN_MENU_AMOUNT) == 0) {
//					m_trigger = false;
//					m_main_select = ++m_main_select >= INDEX_LOGIN_COUNT ? 0 : m_main_select;
//					m_angle_index = ++m_angle_index >= MAIN_MENU_AMOUNT ? 0 : m_angle_index;
//				}
//			}
//			else {// 左
//				m_angle_login += 360 / MAIN_MENU_AMOUNT / 3;
//				if (m_angle_login % (360 / MAIN_MENU_AMOUNT) == 0) {
//					m_trigger = false;
//					m_main_select = --m_main_select < 0 ? INDEX_LOGIN_COUNT - 1 : m_main_select;
//					m_angle_index = --m_angle_index < 0 ? MAIN_MENU_AMOUNT - 1 : m_angle_index;
//				}
//			}
//		}
	}
	private static int exit_progress = 0;
	/**
	 * 询问退出游戏
	 */
	public void exitGame()
	{
	    exit_progress = 1;//日本人
//		final UIMessageBox mbox = (UIMessageBox) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
//		GameManager.s_isControlledByUi = true;
//		mbox.setMessage("是否确定要退出游戏?");
//		mbox.addListener(new UIListener() {
//			public void actionPerformed() {
//				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
//						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
//					GameManager.getInstance().m_test_running = false;
//					GameManager.s_isRunning = false;
//					GameMIDlet.s_isJumpWap = true;
//					UIManager.getInstance().removeWindow(mbox);
//					GameManager.s_isControlledByUi = false;
//				}
//				else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
//					UIManager.getInstance().removeWindow(mbox);
//					GameManager.s_isControlledByUi = false;
//				}
//			}
//		});
	}

	private boolean m_trigger_dir = false;// 转换方向 左-false 右-true

	/**
	 * 用户中心 - 登录游戏逻辑
	 */
	private void loginLogic()
	{
		if (m_if_game) {
			return;
		}
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			m_login_select = m_login_select_list[m_login_select][0];
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			m_login_select = m_login_select_list[m_login_select][1];
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			m_login_select = m_login_select_list[m_login_select][2];
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			m_login_select = m_login_select_list[m_login_select][3];
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
//			exitGame();
		    if (exit_progress == 0) {//日本人
                exitGame();
            } else {
                if (exit_progress == 1) {
                    exit_progress = 0;
                } else if (exit_progress == 2) {
                	Utils.getContext().finish();
                    System.exit(1);
                }
            }
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
		    if (exit_progress != 0) {//日本人
                if (exit_progress == 1) {
                    exit_progress = 2;
                } else if (exit_progress == 2) {
                    try {
                        GameMIDlet.s_instance.platformRequest(GameMIDlet.MORE_GAME_URL);
                    } catch (ConnectionNotFoundException e) {
                        Toast.makeText(Utils.getContext(), "联网失败，请检测网络！", Toast.LENGTH_SHORT).show();
                        e.printStackTrace();
                    }
                    Utils.getContext().finish();
                    System.exit(1);
                }
            } else {
			switch (m_login_select) {
				case LOGIN_INDEX_ZH:
				case LOGIN_INDEX_MM:
					form.deleteAll();
					stringItem.setText("");
					stringItem.setLabel("");

					register_name.setString(m_login_name == null ? "" : m_login_name);
					register_name.setLabel("账号 : ");

					register_password1.setString(m_login_password == null ? "" : m_login_password);
					register_password1.setLabel("密码 : ");

					form.append(register_name);
					form.append(register_password1);
					form.append(stringItem);
					form.addCommand(ok);
					form.addCommand(back);
					form.setCommandListener(this);
					form.setFormButtons();
					Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
					break;
				case LOGIN_INDEX_JZZHJMM:
					m_save_name = !m_save_name;
					GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_WRITE);
					break;
				case LOGIN_INDEX_DLYX:
					if (GameManager.getInstance().getConnection() == null) {
						try {
							GameManager.getInstance().m_game_message.unlockNetwork();
							GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
							GameManager.getInstance().getConnection().open();
						}
						catch (Exception ex) {
							Tools.debug(ex);
						}
					}
				    GameManager.getInstance().m_game_message.sendUserAuth(m_login_name, m_login_password, GAME_VERSION, m_user_id);
				    Tools.debugPrintln("AAAAAAAAAAAAAAAAAAAAAAAA");
					break;
				case LOGIN_INDEX_ZHZC:
					form.deleteAll();
					register_name.setString("");
					register_name.setLabel("账号 : ");
					register_password1.setString("");
					register_password1.setLabel("密码 : ");
					register_password2.setString("");
					register_password2.setLabel("确认密码 : ");
					stringItem.setText("");
					stringItem.setLabel("");
					form.append(register_name);
					form.append(register_password1);
					form.append(register_password2);
					form.append(stringItem);
					form.addCommand(ok);
					form.addCommand(back);
					form.setCommandListener(this);
					form.setFormButtons();
					Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
					break;
				case LOGIN_INDEX_YXSZ:
//					GameTouchManager.backUpRect();
					GameManager.s_isControlledByUi = true;
					UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_SET_SYSTEM);
					break;
				case LOGIN_INDEX_YXBZ:
					GameTouchManager.backUpRect();
					int[][] rect = new int[][]{
							{198,140,82,20},
							{198,160,82,20},
							{0,0,AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT},
					};
					GameManager.s_isControlledByUi = true;
					final UIPopmenu po = (UIPopmenu) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
					registerHelpBtn(rect, po);
					po.setPopmenus(new String[] {"1.游戏帮助", "2.修复游戏"});
					po.addListener(new UIListener() {
						public void actionPerformed() {
							if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
								UIManager.getInstance().removeWindow(po);
								openGameHelp();
							} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
								UIManager.getInstance().removeWindow(po);
								openGameRepair();
							} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
									|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
								UIManager.getInstance().removeWindow(po);
								int index = po.getCurrentIndex();
								switch (index) {
									case 0:
										openGameHelp();
										break;
									case 1:
										openGameRepair();
										break;
								}
								GameTouchManager.recoverRect();
							} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
								GameManager.s_isControlledByUi = false;
								UIManager.getInstance().removeWindow(po);
								GameTouchManager.recoverRect();
							}
						}
					});
					break;
				case LOGIN_INDEX_ZHGL:
					GameTouchManager.backUpRect();
					rect = new int[][]{
							{198,120,82,20},
							{198,140,82,20},
							{198,160,82,20},
							{198,180,82,20},
							{0,0,AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT},
					};

					GameManager.s_isControlledByUi = true;
					final UIPopmenu pop = (UIPopmenu) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
					registerAccountBtn(rect, pop);
					pop.setPopmenus(new String[] {"1.修改密码", "2.账号绑定", "3.找回账号", "4.解除绑定", });
					pop.addListener(new UIListener() {
						public void actionPerformed() {
							if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
								m_account_manage_select = ACCOUNT_MANAGE_PASSWORD;
								changeToChangePassword();
								GameManager.s_isControlledByUi = false;
								UIManager.getInstance().removeWindow(pop);
							} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
								m_account_manage_select = ACCOUNT_MANAGE_BINDING;
								changeToBinding();
								GameManager.s_isControlledByUi = false;
								UIManager.getInstance().removeWindow(pop);
							} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {
								GameManager.s_isControlledByUi = false;
								UIManager.getInstance().removeWindow(pop);
							} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {
								m_account_manage_select = ACCOUNT_MANAGE_UNBIND;
								changeToUnbind();
								GameManager.s_isControlledByUi = false;
								UIManager.getInstance().removeWindow(pop);
							} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
									|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
								int index = pop.getCurrentIndex();
								m_account_manage_select = (byte)index;
								switch (index) {
									case ACCOUNT_MANAGE_PASSWORD:
										changeToChangePassword();
										break;
									case ACCOUNT_MANAGE_BINDING:
										changeToBinding();
										break;
									case ACCOUNT_MANAGE_BACK:
										changeToRetrievePassword();
										break;
									case ACCOUNT_MANAGE_UNBIND:
										changeToUnbind();
										break;
								}
								GameManager.s_isControlledByUi = false;
								UIManager.getInstance().removeWindow(pop);
								GameTouchManager.recoverRect();
							} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
								GameManager.s_isControlledByUi = false;
								UIManager.getInstance().removeWindow(pop);
								GameTouchManager.recoverRect();
							}
						}
					});
					break;
				default:
					setHintMsg("此功能暂未开放!");
					break;
			}
            }
		}
		else {
			// inputMethodKeyPressed();
		}
	}

	private void openGameHelp() {
		final UIMessageBox umb = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		umb.setMessage("温馨提示", null, "返回", HELP_WORD);
		umb.addListener(new UIListener() {
			public void actionPerformed() {
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					GameManager.s_isControlledByUi = false;
					UIManager.getInstance().removeWindow(umb);
				}
			}
		});
	}
	private void openGameRepair() {
		final UIMessageBox umb = (UIMessageBox)UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
		umb.setMessage("游戏修复", "确定", "返回", REPAIR_WORD);
		umb.addListener(new UIListener() {
			public void actionPerformed() {
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
						|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
					try {
						RecordStore.deleteRecordStore(ResourceManager.__STORE_NAME + "_resource");
						RecordStore.deleteRecordStore(ResourceManager.__STORE_NAME + "_catalog");
					} catch (Exception e) {
						Tools.debugPrintln("修复游戏,无数据!");
					}
					setHintMsg("修复成功!");
					GameManager.s_isControlledByUi = false;
					UIManager.getInstance().removeWindow(umb);
				} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					GameManager.s_isControlledByUi = false;
					UIManager.getInstance().removeWindow(umb);
				}
			}
		});
	}
	/**
	 * 切换到修改密码
	 */
	private void changeToChangePassword() {
		form.deleteAll();

		register_name.setLabel("当前账号 : ");
		register_name.setString(m_login_name == null ? "" : m_login_name);
		register_password1.setLabel("当前密码 : ");
		register_password1.setString(m_login_password == null ? "" : m_login_password);
		register_password2.setLabel("新密码 : ");
		register_password2.setString("");
		register_password3.setLabel("确认新密码 : ");
		register_password3.setString("");

		stringItem.setText("");
		stringItem.setLabel("");

		form.append(register_name);
		form.append(register_password1);
		form.append(register_password2);
		form.append(register_password3);
		form.append(stringItem);

		form.addCommand(ok);
		form.addCommand(back);
		form.setCommandListener(this);
		form.setFormButtons();
		Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
	}
	/**
	 * 切换到账号绑定
	 */
	private void changeToBinding() {
		form.deleteAll();

		register_name.setLabel("账号 : ");
		register_name.setString(m_login_name == null ? "" : m_login_name);
		register_password1.setLabel("密码 : ");
		register_password1.setString(m_login_password == null ? "" : m_login_password);
		register_phone.setLabel("绑定手机号 : ");
		register_phone.setString("");
		register_email.setLabel("绑定邮箱 : ");
		register_email.setString("");

		stringItem.setText("");
		stringItem.setLabel("");

		register_hint.setText("绑定手机号方便您找回自己的账号密码。请仔细确认输入手机号和邮箱的正确性。");

		form.append(register_name);
		form.append(register_password1);
		form.append(register_phone);
		form.append(register_email);
		form.append(stringItem);
		form.append(register_hint);
		form.addCommand(ok);
		form.addCommand(back);
		form.setCommandListener(this);
		form.setFormButtons();
		Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
	}

	/**
	 * 切换到解除账号绑定
	 */
	private void changeToUnbind() {
		form.deleteAll();

		register_name.setLabel("账号 : ");
		register_name.setString(m_login_name == null ? "" : m_login_name);
		register_password1.setLabel("密码 : ");
		register_password1.setString(m_login_password == null ? "" : m_login_password);

		stringItem.setText("");
		stringItem.setLabel("");

		form.append(register_name);
		form.append(register_password1);
		form.append(stringItem);

		form.addCommand(ok);
		form.addCommand(back);
		form.setCommandListener(this);
		form.setFormButtons();
		Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
	}

	/**
	 * 切换到密码找回
	 */
	private void changeToRetrievePassword() {
		form.deleteAll();

		register_phone.setLabel("已绑定的手机号 : ");
		register_phone.setString("");
		register_email.setLabel("已绑定的邮箱 : ");
		register_email.setString("");

		stringItem.setText("");
		stringItem.setLabel("");

		register_hint.setText("选择手机号或者邮箱一种输入。就可以收到账号密码信息。");

		form.append(register_phone);
		form.append(register_email);
		form.append(stringItem);
		form.append(register_hint);
		form.addCommand(ok);
		form.addCommand(back);
		form.setCommandListener(this);
		form.setFormButtons();
		Display.getDisplay(GameMIDlet.s_instance).setCurrent(form);
	}

	private int m_auto_register_time = 0;

	/**
	 * 用户中心 - 快速注册逻辑
	 */
	private void quickLogic()
	{
//		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
//			if (m_quick_select != 2 && m_quick_select != 6) {
//				if (m_quick_select > 1) {
//					m_quick_box_content[m_quick_select - 1] += m_input_chars;
//					clearInput();
//				}
//				else {
//					m_quick_box_content[m_quick_select] += m_input_chars;
//					clearInput();
//				}
//			}
//			m_quick_select = (byte) (--m_quick_select < 0 ? QUICK_BOX_PROPERTY.length - 1 : m_quick_select);
//			if (m_quick_select != 2 && m_quick_select != 6) {
//				if (m_quick_select > 1) {
//					addInputChars(m_quick_box_content[m_quick_select - 1]);
//					m_quick_box_content[m_quick_select - 1] = "";
//				}
//				else {
//					addInputChars(m_quick_box_content[m_quick_select]);
//					m_quick_box_content[m_quick_select] = "";
//				}
//			}
//		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
//			if (m_quick_select != 2 && m_quick_select != 6) {
//				if (m_quick_select > 1) {
//					m_quick_box_content[m_quick_select - 1] += m_input_chars;
//					clearInput();
//				}
//				else {
//					m_quick_box_content[m_quick_select] += m_input_chars;
//					clearInput();
//				}
//			}
//			m_quick_select = (byte) (++m_quick_select == QUICK_BOX_PROPERTY.length ? 0 : m_quick_select);
//			if (m_quick_select != 2 && m_quick_select != 6) {
//				if (m_quick_select > 1) {
//					addInputChars(m_quick_box_content[m_quick_select - 1]);
//					m_quick_box_content[m_quick_select - 1] = "";
//				}
//				else {
//					addInputChars(m_quick_box_content[m_quick_select]);
//					m_quick_box_content[m_quick_select] = "";
//				}
//			}
//		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
//			if (m_quick_select == 2) {
//				GameManager.getInstance().m_game_message.sendUserAuth(m_quick_box_content[0], m_quick_box_content[1], "1.0.0");
//			} else if (m_quick_select == 6) {
//
//			}
//		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
//			setNextState(STATE_LOGIN_MAIN);
//		}
//		else {
//			inputMethodKeyPressed();
//		}
	}

	public void paint(Graphics g)
	{
		if (m_user_state < 0) {
			return;
		}
		if (m_user_state == STATE_LOGO) {
			drawLogoScreen(g);
			return;
		} else if (m_user_state == STATE_LOADING || m_user_state == STATE_LOGIN_BACK) {
			drawLoadingScreen(g);
			return;
		} else if (m_user_state == STATE_LOGIN_SOUND) {
//			drawSoundScreen(g);//日本人
			if( !GameMIDlet.isHaveIP ){
				GameManager.getInstance().m_game_message.drawNetworkIcon(g,
						GameManager.getInstance().img_lock_network,
						AbstractGameScreen.SCREEN_WIDTH >> 1,
						AbstractGameScreen.SCREEN_HEIGHT >> 1, m_timer & 0x03);
			}
			return;
		}
		clearScreen(g, Tools.GRAY);
		UITools.drawAlphaBG(g);
		switch (m_user_state) {
			case STATE_LOGIN_MAIN:
				drawMainScreen(g);
				if (m_httpconnect) {
					GameManager.getInstance().m_game_message.drawNetworkIcon(g,
							GameManager.getInstance().img_lock_network,
							AbstractGameScreen.SCREEN_WIDTH >> 1,
							AbstractGameScreen.SCREEN_HEIGHT >> 1, m_timer & 0x03);
				}
				break;
			case STATE_LOGIN_REG:
//				drawQuickScreen(g);
				break;
			case STATE_LOGIN_LOGIN:
				drawLoginScreen(g);
//				drawTestHTTP(g);
				break;
			case STATE_LOGIN_HELP:
				drawHelpScreen(g);
				break;
			case STATE_LOGIN_TOPUP:
				break;
			case STATE_LOGIN_REPAIT:
				break;
			case STATE_LOGIN_SET:
				drawSetScreen(g);
				break;
			case STATE_LOGIN_ROLES:
				drawRoleScreen(g);
				break;
			case STATE_LOGIN_SERVER:
				drawServerScreen(g);
				break;
			case STATE_LOGIN_CREATE:
				drawCreateScreen(g);
				break;
			case STATE_LOGIN_NEW_REG:
				break;
			case STATE_LOGIN_NEW_LOGIN:
				drawNewLogin(g);
				break;
		}
		if (m_hintTimer > 0) {
			g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//			drawRect(g,
//					118 - (AbstractGameScreen.s_font.stringWidth(m_hintMsg) >> 1),
//					100, AbstractGameScreen.s_font.stringWidth(m_hintMsg) + 4,
//					20, Tools.WHITE, Tools.BLACK, (byte) 0);
//			drawColorString(g, m_hintMsg, AbstractGameScreen.SCREEN_WIDTH >> 1, 102, Tools.BLACK, Tools.HCENTER_TOP);
			Tools.drawString(g, Tools.WHITE, Tools.BLACK, m_hintMsg,
					AbstractGameScreen.SCREEN_WIDTH >> 1, AbstractGameScreen.SCREEN_HEIGHT / 3, Tools.HCENTER_TOP);
		}
		if (m_star_list != null) {
			g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
			for (int i = 0; i < m_star_list.size(); i++) {
				Star star = (Star) m_star_list.elementAt(i);
				if (star.m_type == star.TYPE_SMALL) {
					star.drawStar(g, img_small_star);
				}
				else {
					star.drawStar(g, img_big_star);
				}
			}
		}
		UIManager.getInstance().paint(g);
		if (GameManager.getInstance().m_game_message.isLockNetwork()) {
			GameManager.getInstance().m_game_message.drawNetworkIcon(g,
					GameManager.getInstance().img_lock_network,
					AbstractGameScreen.SCREEN_WIDTH >> 1,
					AbstractGameScreen.SCREEN_HEIGHT >> 1, m_timer % 4);
		}

	}
	//#if screen == "320240"
	//# private final int H_SCREEN_N_1 = AbstractGameScreen.SCREEN_HEIGHT / 8;
	//# private final int W_SCREEN_N_1 = AbstractGameScreen.SCREEN_WIDTH / 8;
	//# private final int O_SCREEN = -25;
	//#else
	private final int H_SCREEN_N_1 = AbstractGameScreen.SCREEN_HEIGHT / 10;
	private final int W_SCREEN_N_1 = AbstractGameScreen.SCREEN_WIDTH / 10;
	private final int O_SCREEN = 0;
	//#endif
	private void drawNewLogin(Graphics g)
	{
		drawBackground(g, 0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT, WORD_INDEX_DL);

		if (img_word_list == null) {
			return;
		}
		int m_rect_w = 20;
		int m_rect_h = 10;
		int x = 0, y = 0;
		Image img = img_word_list[WORD_INDEX_ZH];
		// 绘制账号
		if (img != null) {
			x = W_SCREEN_N_1 * 1 + img.getWidth() + m_rect_w + 10;
			y = H_SCREEN_N_1 * 2;
			drawRectByWord(g, W_SCREEN_N_1 * 1, H_SCREEN_N_1 * 2, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_ZH, true);
			if (m_login_select == LOGIN_INDEX_ZH) {
				g.setColor(0x3A2010);
				g.drawRect(x - 3, y - 3, WIDTH_SCREEN_4_1 * 2 + 6, img.getHeight() + m_rect_h + 6);
				g.setColor(0xF5FB7C);
				g.fillRect(x - 2, y - 2, WIDTH_SCREEN_4_1 * 2 + 5, img.getHeight() + m_rect_h + 5);
			}
			g.setColor(0x3A2010);
			g.fillRect(x, y, WIDTH_SCREEN_4_1 * 2, img.getHeight() + m_rect_h);
			g.setColor(0xebeb8b);
			g.drawRect(x, y, WIDTH_SCREEN_4_1 * 2, img.getHeight() + m_rect_h);

			if (m_login_name != null) {
				drawColorString(g, m_login_name, x + 6, y + ((img.getHeight() + m_rect_h - AbstractGameScreen.FONT_H) >> 1), Tools.WHITE, Tools.LEFT_TOP);
			}

		}
		// 绘制密码
		img = img_word_list[WORD_INDEX_MM];
		if (img != null) {
			x = W_SCREEN_N_1 * 1 + img.getWidth() + m_rect_w + 10;
			y = H_SCREEN_N_1 * 3;
			drawRectByWord(g, W_SCREEN_N_1 * 1, H_SCREEN_N_1 * 3, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_MM, true);
			if (m_login_select == LOGIN_INDEX_MM) {
				g.setColor(0x3A2010);
				g.drawRect(x - 3, y - 3, WIDTH_SCREEN_4_1 * 2 + 6, img.getHeight() + m_rect_h + 6);
				g.setColor(0xF5FB7C);
				g.fillRect(x - 2, y - 2, WIDTH_SCREEN_4_1 * 2 + 5, img.getHeight() + m_rect_h + 5);
			}
			g.setColor(0x3A2010);
			g.fillRect(x, y, WIDTH_SCREEN_4_1 * 2, img.getHeight() + m_rect_h);
			g.setColor(0xebeb8b);
			g.drawRect(x, y, WIDTH_SCREEN_4_1 * 2, img.getHeight() + m_rect_h);
			if (m_login_password != null) {
				if (m_login_password != null && !m_login_password.equals("")) {
					String temp = "";
					for (int i = 0; i < m_login_password.length(); i++) {
						temp += "*";
					}
					drawColorString(g, temp, x + 6, y + 2 + ((img.getHeight() + m_rect_h - AbstractGameScreen.FONT_H) >> 1), Tools.WHITE, Tools.LEFT_TOP);
				}
			}
		}
		// 绘制登录游戏
		img = img_word_list[WORD_INDEX_DLYX];
		if (img != null) {
			if (m_login_select == 2) {
				drawRectByWord(g, WIDTH_SCREEN_2_1 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 5, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_DLYX, false);
			} else {
				drawRectByWord(g, WIDTH_SCREEN_2_1 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 5, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_DLYX, true);
			}
		}

		drawBottomButton(g, true, true);
	}

//	private void drawTestHTTP(Graphics g){
//		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//		g.setColor(0xFF0000);
//		if( HttpConnect.NUMBER != null ){
//			g.drawString("号码："+HttpConnect.NUMBER, 50, 190, 0);
//		}else{
//			g.drawString("状态："+HttpConnect.s_success, 50, 190, 0);
//		}
//	}

	private void drawSoundScreen(Graphics g) {
		g.setColor(Tools.BLACK);
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		g.fillRect(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		if (img_logo != null && img_logo.length > 1) {
			if (img_logo[1] != null) {
				g.drawImage(img_logo[1], AbstractGameScreen.SCREEN_WIDTH >> 1, 20, Tools.HCENTER_TOP);
				if (m_sound_text != null) {
					for (int i = 0; i < m_sound_text.length; i++) {
						drawColorString(g, m_sound_text[i], AbstractGameScreen.SCREEN_WIDTH >> 1,
								img_logo[1].getHeight() + 60 + i * AbstractGameScreen.FONT_H, Tools.WHITE, Tools.HCENTER_TOP);
					}
				}
			}
		}
//		Log.d("Png", "font size="+g.mPaint.getTextSize());
//		if (Tools.DEBUG) {
//			if (!m_port) {
//				g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//				int ty = (AbstractGameScreen.SCREEN_HEIGHT - SERVER_LIST_IP.length * 20) >> 1;
//				for (int i = 0; i < SERVER_LIST_IP.length; i++) {
//					drawRect(g, 0, ty + i * 20, AbstractGameScreen.SCREEN_WIDTH, 20, Tools.WHITE, Tools.BLACK, (byte) (m_port_select == i ? -1 : 0));
//					drawColorString(g, SERVER_LIST_IP[i] + " : " + SERVER_LIST_PORT[i],
//							AbstractGameScreen.SCREEN_WIDTH >> 1, ty + 2 + i * 20, m_port_select == i ? Tools.WHITE : Tools.BLACK, Tools.HCENTER_TOP);
//				}
//			}
//		}
		drawRectByWord(g, 0, AbstractGameScreen.SCREEN_HEIGHT - SOFTKEY_H - 1, SOFTKEY_W, SOFTKEY_H, WORD_INDEX_KQ, true);
		drawRectByWord(g, AbstractGameScreen.SCREEN_WIDTH - SOFTKEY_W - 1,
				AbstractGameScreen.SCREEN_HEIGHT - SOFTKEY_H - 1, SOFTKEY_W, SOFTKEY_H, WORD_INDEX_GB, true);
	}

	private final int SOFTKEY_W = 50;
	private final int SOFTKEY_H = 20;
	private final String[] m_sound_text = UITools.splitString("是否开启声音?(5秒后默认为关闭)", AbstractGameScreen.SCREEN_WIDTH / 3 * 2);


	private void drawLoadingScreen(Graphics g)
	{
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		UITools.drawColorFillRect(g, 0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT, Tools.BLACK);
		UITools.drawColorString(g, "加载中...", AbstractGameScreen.SCREEN_WIDTH >> 1, AbstractGameScreen.SCREEN_HEIGHT >> 1, Tools.WHITE, Tools.HCENTER_TOP);
	}

	private void drawLogoScreen(Graphics g)
	{
		if (m_logo_index <= LOGO_TIME.length) {
			if (m_logo_index > 0) {
				g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
				UITools.drawColorFillRect(g, 0, 0, AbstractGameScreen.SCREEN_WIDTH,
						AbstractGameScreen.SCREEN_HEIGHT, (m_logo_index == 3 ? Tools.WHITE : Tools.BLACK));
				g.drawImage(img_logo[m_logo_index - 1], AbstractGameScreen.SCREEN_WIDTH >> 1,
						AbstractGameScreen.SCREEN_HEIGHT >> 1, Tools.HCENTER_VCENTER);
			}
		}
	}

	private void clearScreen(Graphics g, int color)
	{
		g.setColor(color);
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		g.fillRect(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		if (img_background != null) {
			g.drawImage(img_background, 0, 0, Tools.LEFT_TOP);
		}
		if (m_user_state == STATE_LOGIN_MAIN) {
			if (img_logo != null && img_logo.length > 1 && img_logo[1] != null) {
				g.drawImage(img_background_logo, AbstractGameScreen.SCREEN_WIDTH >> 1, 0, Tools.HCENTER_TOP);
			}
		}
	}

	private int m_sex_index = 0;
	private int m_job_index = 0;
	private int m_race_index = 0;
	private final String[] CREATE_SEX = { "男", "女" };
	private final String[] CREATE_JOB = { "剑客", "武者", "道士" };
	private final String[] CREATE_RACE = { "仙", "妖", "人", "鬼" };

	private final String[] CREATE_RES_SEX = { "m_", "f_" };
	private final String[] CREATE_RES_JOB = { "jk_", "dk_", "fs_" };
	private final String[] CREATE_RES_RACE = { "x_", "y_", "r_", "g_" };
	private final String[] CREATE_RES_FASHION = { "1" };

	private final byte CREATE_SEX_AMOUNT = 2;
	private final byte CREATE_JOB_AMOUNT = 3;
	private final byte CREATE_RECE_AMOUNT = 4;

	private String[] m_create_msg = null;
	private String CREATE_ROLE_MSG = "";
	private int m_create_msg_index = 0;

	/**
	 * 创建人物界面
	 *
	 * @param g
	 */
	private void drawCreateScreen(Graphics g)
	{
		drawBackground(g, 0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT, WORD_INDEX_CJJM);

//		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//		drawColorString(g, "创建界面", AbstractGameScreen.SCREEN_WIDTH >> 1, 2, Tools.WHITE, Tools.HCENTER_TOP);

		if (img_word_list == null) {
			return;
		}
		// 绘制人物效果
		if (m_create_role != null) {
			int shimmy = (m_timer % 8) / 2;
			//#if screen == "640360"
			 m_actor_flower.m_posX = (m_flower_w >> 1) + 30;
			 m_actor_flower.m_posY = 115 + m_shimmys[shimmy];
			 m_actor_flower.draw(g, 0, 0);
			 m_create_role.m_posX = (m_flower_w >> 1) + 30;
			 m_create_role.m_posY = m_actor_flower.m_posY - 15;
			 m_create_role.dr(g);
			//#elif screen == "320240"
			//# m_actor_flower.m_posX = (m_flower_w >> 1) + 40;
			//# m_actor_flower.m_posY = 115 + m_shimmys[shimmy];
			//# m_actor_flower.draw(g, 0, 0);
			//# m_create_role.m_posX = (m_flower_w >> 1) + 40;
			//# m_create_role.m_posY = m_actor_flower.m_posY - 15;
			//# m_create_role.dr(g);
			//#else
//			m_actor_flower.m_posX = m_flower_w >> 1;
//			m_actor_flower.m_posY = 115 + m_shimmys[shimmy];
//			m_actor_flower.draw(g, 0, 0);
//			m_create_role.m_posX = m_flower_w >> 1;
//			m_create_role.m_posY = m_actor_flower.m_posY - 15;
//			m_create_role.dr(g);
			//#endif
		}

		// 信息框
		drawMsgRect(g, X_CREATE_MSG, Y_CREATE_MSG, W_CREATE_MSG, H_CREATE_MSG);
		if (m_create_msg != null) {
			UITools.drawStringList(g, m_create_msg, X_CREATE_MSG + 4, Y_CREATE_MSG + 3, m_create_msg_index,
					(H_CREATE_MSG - 8) / UITools.H_SINGLE_BAR, UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
			int len = m_create_msg.length - (H_CREATE_MSG - 8) / UITools.H_SINGLE_BAR;
			if (len > 0) {
				UITools.paintScrollBar(g, X_CREATE_MSG + W_CREATE_MSG, Y_CREATE_MSG, H_CREATE_MSG,
						m_create_msg_index * 100 / (m_create_msg.length - (H_CREATE_MSG - 8) / UITools.H_SINGLE_BAR));
			}
		}



		// 框体
//		drawMsgRect(g, X_CREATE_SEX - 70, Y_CREATE_SEX - 2, 45,
//				AbstractGameScreen.FONT_H + 6, Tools.BLACK, 0xDDDDA0, 0x502A2A);// 性别框
//		drawMsgRect(g, X_CREATE_SEX - 70, Y_CREATE_JOB - 2, 45,
//				AbstractGameScreen.FONT_H + 6, Tools.BLACK, 0xDDDDA0, 0x502A2A);// 职业框
//		drawMsgRect(g, X_CREATE_SEX - 70, Y_CREATE_RACE - 2, 45,
//				AbstractGameScreen.FONT_H + 6, Tools.BLACK, 0xDDDDA0, 0x502A2A);// 种族框

		// 性别
		Image img = img_word_list[WORD_INDEX_XB];
		int w = img.getWidth() + m_rect_w;
		int h = img.getHeight() + m_rect_h;
		drawRectByWord(g, X_CREATE_SEX - (w >> 1), Y_CREATE_SEX, w, h, WORD_INDEX_XB, true);
		img = img_word_list[WORD_INDEX_ZY];
		drawRectByWord(g, X_CREATE_SEX - (w >> 1), Y_CREATE_JOB, w, h, WORD_INDEX_ZY, true);
		img = img_word_list[WORD_INDEX_ZZ];
		drawRectByWord(g, X_CREATE_SEX - (w >> 1), Y_CREATE_RACE, w, h, WORD_INDEX_ZZ, true);

		drawMsgRect(g, X_CREATE_SEX + (w >> 1) + 5, Y_CREATE_SEX, 100, h + 1);// 性别图标框
		drawMsgRect(g, X_CREATE_SEX + (w >> 1) + 5, Y_CREATE_JOB, 100, h + 1);// 职业图标框
		drawMsgRect(g, X_CREATE_SEX + (w >> 1) + 5, Y_CREATE_RACE, 100, h + 1);// 种族图标框


		// 职业图标
		for (int i = 0; i < CREATE_JOB_AMOUNT; i++) {
			drawImagePart(g, img_job, X_CREATE_JOB + w + (W_BOX_SEX + 4) * i,
					Y_CREATE_JOB + (h + 1 - (img_job.getHeight() >> 1) >> 1), W_BOX_SEX, H_BOX_SEX, i, m_job_index == i ? 0 : 1);// 剑,武,道
		}
		// 种族图标
		for (int i = 0; i < CREATE_RECE_AMOUNT; i++) {
			drawImagePart(g, img_race, X_CREATE_RACE + w + (W_BOX_SEX + 4) * i,
					Y_CREATE_RACE + (h + 1 - (img_race.getHeight() >> 1) >> 1), W_BOX_SEX, H_BOX_SEX, i, m_race_index == i ? 0 : 1);// 神,人,妖,鬼
		}
		// 性别图标
		for (int i = 0; i < CREATE_SEX_AMOUNT; i++) {
			drawImagePart(g, img_sex, X_CREATE_SEX + w + (W_BOX_SEX << 1) * i,
					Y_CREATE_SEX + (h + 1 - (img_sex.getHeight() >> 1) >> 1), W_BOX_SEX, H_BOX_SEX, i, m_sex_index == i ? 0 : 1);// 男,女
		}

		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);

		// 名字框
		img = img_word_list[WORD_INDEX_NC];
		drawRectByWord(g, X_CREATE_NAME - w, Y_CREATE_NAME, w, h, WORD_INDEX_NC, true);
		//#if screen == "640360"
		 drawMsgRect(g, X_CREATE_NAME + 3, Y_CREATE_NAME - 5, W_CREATE_NAME, h + 1 + 10);
		//#else
//		drawMsgRect(g, X_CREATE_NAME + 3, Y_CREATE_NAME, W_CREATE_NAME, h + 1);
		//#endif
		drawColorString(g, m_role_name, X_CREATE_NAME + 8, Y_CREATE_NAME + (h - AbstractGameScreen.FONT_H >> 1), Tools.WHITE, Tools.LEFT_TOP);

		switch (m_create_select) {
			case INDEX_CREATE_SEX:
				drawImageCursor(g, X_CREATE_SEX + w - 4 + (W_BOX_SEX << 1) * m_sex_index, Y_CREATE_SEX - 2);
				break;
			case INDEX_CREATE_JOB:
				drawImageCursor(g, X_CREATE_JOB + w - 4 + (W_BOX_SEX + 4) * m_job_index, Y_CREATE_JOB - 2);
				break;
			case INDEX_CREATE_RACE:
				drawImageCursor(g, X_CREATE_RACE + w - 4 + (W_BOX_SEX + 4) * m_race_index, Y_CREATE_RACE - 2);
				break;
			case INDEX_CREATE_NAME:
				//#if screen == "640360"
				drawColorRect(g, X_CREATE_NAME + 1, Y_CREATE_NAME - 1 - 5, W_CREATE_NAME + 3, h + 3 + 10, 0x550a00, 0xf3fd76, 0xf3fd76);
				//#else
//				drawColorRect(g, X_CREATE_NAME + 1, Y_CREATE_NAME - 1, W_CREATE_NAME + 3, h + 3, 0x550a00, 0xf3fd76, 0xf3fd76);
				//#endif
				drawColorString(g, "输入名字", AbstractGameScreen.SCREEN_WIDTH >> 1, AbstractGameScreen.SCREEN_HEIGHT, -1, Tools.HCENTER_BOTTOM);
				break;
			case INDEX_CREATE_MSG:
				drawColorRect(g, X_CREATE_MSG - 1, Y_CREATE_MSG - 1, W_CREATE_MSG + 1, H_CREATE_MSG + 1, 0x550a00, 0xf3fd76, 0xf3fd76);
				break;
		}
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		img = img_word_list[WORD_INDEX_CJJS];
		w = img.getWidth() + m_rect_w;
		//#if screen == "320240"
		//# if (m_create_select == INDEX_CREATE_CREATE) {
		//# drawRectByWord(g, WIDTH_SCREEN_4_1 * 3 - (w >> 1), Y_CREATE_NAME + h + 10, w, h, WORD_INDEX_CJJS, false);
		//# } else {
		//# drawRectByWord(g, WIDTH_SCREEN_4_1 * 3 - (w >> 1), Y_CREATE_NAME + h + 10, w, h, WORD_INDEX_CJJS, true);
		//# }
		//#else
		if (m_create_select == INDEX_CREATE_CREATE) {
			drawRectByWord(g, WIDTH_SCREEN_2_1 - (w >> 1), Y_CREATE_NAME + h + 10, w, h, WORD_INDEX_CJJS, false);
		} else {
			drawRectByWord(g, WIDTH_SCREEN_2_1 - (w >> 1), Y_CREATE_NAME + h + 10, w, h, WORD_INDEX_CJJS, true);
		}
		//#endif

		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		drawBottomButton(g, true, true);
	}

	/**
	 * 绘制图片的一部分
	 *
	 * @param img
	 * @param x
	 * @param y
	 * @param w
	 * 单块宽
	 * @param h
	 * 单块高
	 * @param indexW
	 * 横向索引
	 * @param indexH
	 * 纵向索引
	 */
	private void drawImagePart(Graphics g, Image img, int x, int y, int w,
			int h, int indexW, int indexH)
	{
		g.setClip(x, y, w, h);
		g.drawImage(img, x - indexW * w, y - indexH * h, Tools.LEFT_TOP);
	}

	private final int[] CURSOR_TRANS = { Tools.TRANS_NONE, Tools.TRANS_270, Tools.TRANS_HV, Tools.TRANS_90 };

	private void drawImageCursor(Graphics g, int x, int y)
	{
		g.setClip(x, y, img_cursor_corner.getWidth(), img_cursor_corner.getHeight());
		int timer = m_timer % 8;
		if (timer % 2 == 0) {
			Tools.drawRegion(g, img_cursor_corner, x, y, CURSOR_TRANS[timer >> 1], Tools.LEFT_TOP);
		} else {
			Tools.drawRegion(g, img_cursor_side, x, y, CURSOR_TRANS[timer >> 1], Tools.LEFT_TOP);
		}
	}

	/**
	 * 选择人物界面
	 *
	 * @param g
	 */
	private void drawRoleScreen(Graphics g)
	{
		drawBackground(g, 0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT, WORD_INDEX_RWJM);
		// 信息框
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);

		drawMsgRect(g, X_ACTOR_MSG, Y_ACTOR_MSG, WIDTH_ACTOR_MSG, HEIGHT_ACTOR_MSG);
		if (m_role_list[m_role_select] != null && m_role_list[m_role_select].m_vocation != null) {
			//#if screen == "320240"
			//# ActorRole selectRole = m_role_list[m_role_select];
			//# drawColorString(g, "名称 : " + selectRole.m_name, X_ACTOR_MSG + 5, Y_ACTOR_MSG + 3, Tools.WHITE, Tools.LEFT_TOP);
			//# drawColorString(g, "等级 : " + selectRole.m_lv, X_ACTOR_MSG + 5, Y_ACTOR_MSG + 23, Tools.WHITE, Tools.LEFT_TOP);
			//# drawColorString(g, "性别 : " + ActorRole.ROLE_SEX_LIST[selectRole.m_sex], X_ACTOR_MSG + 5, Y_ACTOR_MSG + 43, Tools.WHITE, Tools.LEFT_TOP);
			//# drawColorString(g, "种族 : " + ActorRole.ROLE_RACE_LIST[selectRole.m_race], X_ACTOR_MSG + 5, Y_ACTOR_MSG + 63, Tools.WHITE, Tools.LEFT_TOP);
			//# drawColorString(g, "职业 : " + ActorRole.ROLE_VOCATION_LIST[selectRole.m_vocation[selectRole.m_vocation.length - 1]],
			//# 		X_ACTOR_MSG + 5, Y_ACTOR_MSG + 83, Tools.WHITE, Tools.LEFT_TOP);
			//# drawColorString(g, "离线场景 : " + selectRole.m_location,
			//# 		X_ACTOR_MSG + 5, Y_ACTOR_MSG + 103, Tools.WHITE, Tools.LEFT_TOP);
			//#else
			ActorRole selectRole = m_role_list[m_role_select];
			drawColorString(g, "名称 : " + selectRole.m_name, X_ACTOR_MSG + 5, Y_ACTOR_MSG + 3, Tools.WHITE, Tools.LEFT_TOP);
			drawColorString(g, "等级 : " + selectRole.m_lv + ", 性别 : " + ActorRole.ROLE_SEX_LIST[selectRole.m_sex],
					X_ACTOR_MSG + 5, Y_ACTOR_MSG + 23, Tools.WHITE, Tools.LEFT_TOP);
			drawColorString(g, "种族 : " + ActorRole.ROLE_RACE_LIST[selectRole.m_race]
							+ ", 职业 : " + ActorRole.ROLE_VOCATION_LIST[selectRole.m_vocation[selectRole.m_vocation.length - 1]],
							X_ACTOR_MSG + 5, Y_ACTOR_MSG + 43, Tools.WHITE, Tools.LEFT_TOP);
			drawColorString(g, "离线场景 : " + selectRole.m_location,
					X_ACTOR_MSG + 5, Y_ACTOR_MSG + 63, Tools.WHITE, Tools.LEFT_TOP);
			//#endif
		}

		drawColorString(g, "服务器名称 : " + GameManager.getInstance().m_server_name, AbstractGameScreen.SCREEN_WIDTH >> 1, Y_BG + 2, 0xF8EC89, Tools.HCENTER_TOP);

		if (m_role_lock) {
			g.drawImage(img_word_list[WORD_INDEX_DQRWLB], AbstractGameScreen.SCREEN_WIDTH >> 1, AbstractGameScreen.SCREEN_HEIGHT / 3, Tools.HCENTER_VCENTER);
		}
		else {
			for (int i = 0; i < m_role_list.length; i++) {
				//#if screen == "320240"
				//# int targetX = WIDTH_SCREEN_3_1 - 17 - (Tools.sin(i * (360 / 3) + m_angle_create << Tools.BITS) * 60 >> Tools.BITS);
				//# int targetY = 130 + (Tools.cos(i * (360 / 3) + m_angle_create << Tools.BITS) * 30 >> Tools.BITS);
				//#else
				int targetX = WIDTH_SCREEN_2_1 + 3 - (Tools.sin(i * (360 / 3) + m_angle_create << Tools.BITS) * 80 >> Tools.BITS);
				int targetY = 130 + (Tools.cos(i * (360 / 3) + m_angle_create << Tools.BITS) * 30 >> Tools.BITS);
				//#endif
				ActorRole role = m_role_list[i];
				if (i == m_role_select) {
					if (role == null) {
						g.drawImage(img_lianhua, targetX, targetY, Tools.HCENTER_VCENTER);
						g.drawImage(img_delete_role, targetX, targetY, Tools.HCENTER_BOTTOM);
						//#if screen == "320240"
						//# drawColorString(g, "创建角色", WIDTH_SCREEN_3_1 - 13, 80, Tools.WHITE, Tools.HCENTER_TOP);
						//#else
						drawColorString(g, "创建角色", WIDTH_SCREEN_2_1 + 3, 80, Tools.WHITE, Tools.HCENTER_TOP);
						//#endif
					}
					else {
						drawColorString(g, role.m_name, targetX, targetY - 80, Tools.WHITE, Tools.HCENTER_TOP);
						if (role.m_delete) {
							g.drawImage(img_lianhua, targetX, targetY, Tools.HCENTER_VCENTER);
							g.drawImage(img_delete_role, targetX, targetY, Tools.HCENTER_BOTTOM);
							drawColorString(g, "保留剩余天数 : " + role.m_keep_day,
									targetX, targetY + 20, Tools.WHITE, Tools.HCENTER_TOP);
						}
						else {
							int shimmy = (m_timer % 8) / 2;
							m_actor_flower.m_posX = targetX;
							m_actor_flower.m_posY = targetY + 15 + m_shimmys[shimmy];
							m_actor_flower.draw(g, 0, 0);
							role.m_posX = targetX;
							role.m_posY = targetY + m_shimmys[shimmy];
							role.dr(g);
						}
						drawRoleMenu(g, role);
					}
				}
				else {
					if (role == null) {
						g.drawImage(img_lianhua, targetX, targetY, Tools.HCENTER_VCENTER);
						g.drawImage(img_delete_role, targetX, targetY, Tools.HCENTER_BOTTOM);
					}
					else {
						drawColorString(g, role.m_name, targetX, targetY - 80, Tools.WHITE, Tools.HCENTER_TOP);
						if (role.m_delete) {
							g.drawImage(img_lianhua, targetX, targetY, Tools.HCENTER_VCENTER);
							g.drawImage(img_delete_role, targetX, targetY, Tools.HCENTER_BOTTOM);
						}
						else {
							g.drawImage(img_lianhua, targetX, targetY, Tools.HCENTER_VCENTER);
							role.m_posX = targetX;
							role.m_posY = targetY;
							role.dr(g);
						}
					}
				}
			}
		}
	    //drawColorString(g, "#键选择服务器", AbstractGameScreen.SCREEN_WIDTH >> 1, AbstractGameScreen.SCREEN_HEIGHT, 0xF8EC89, Tools.HCENTER_BOTTOM);
		drawBottomButton(g, true, true);
	}

	private int[] m_shimmys = new int[] { 0, 1, 2, 1 };

	private void drawRoleMenu(Graphics g, ActorRole role)
	{
		if (m_role_menu) {
			if (role.m_delete) {
				Image img = img_word_list[WORD_INDEX_HYJS];
				int w = img.getWidth() + m_rect_w;
				int h = img.getHeight() + m_rect_h;
				//#if screen == "320240"
				//# int x = WIDTH_SCREEN_2_1 + 20 - w >> 1;
				//# int y = AbstractGameScreen.SCREEN_HEIGHT + 80 - h * 3 >> 1;
				//#else
				int x = AbstractGameScreen.SCREEN_WIDTH - w >> 1;
				int y = AbstractGameScreen.SCREEN_HEIGHT - h * 3 >> 1;
				//#endif
				drawMsgRect(g, x, y, w, h * 2);
				g.setColor(Tools.YELLOW);
				g.fillRect(x + 3, y + 3 + m_role_menu_select * h, w - 6, h - 6);
				g.drawImage(img_word_list[WORD_INDEX_HYJS], x + (m_rect_w >> 1), y + (m_rect_h >> 1), Tools.LEFT_TOP);
				g.drawImage(img_word_list[WORD_INDEX_FH], x + (m_rect_w >> 1), y + (m_rect_h >> 1) + h, Tools.LEFT_TOP);
			}
			else {
				Image img = img_word_list[WORD_INDEX_JRYX];
				int w = img.getWidth() + m_rect_w;
				int h = img.getHeight() + m_rect_h;
				//#if screen == "320240"
				//# int x = WIDTH_SCREEN_2_1 + 20 - w >> 1;
				//# int y = AbstractGameScreen.SCREEN_HEIGHT + 80 - h * 3 >> 1;
				//#else
				int x = AbstractGameScreen.SCREEN_WIDTH - w >> 1;
				int y = AbstractGameScreen.SCREEN_HEIGHT - h * 3 >> 1;
				//#endif
				drawMsgRect(g, x, y, w, h * 3);
				g.setColor(Tools.YELLOW);
				g.fillRect(x + 3, y + 3 + m_role_menu_select * h, w - 6, h - 6);
				g.drawImage(img_word_list[WORD_INDEX_JRYX], x + (m_rect_w >> 1), y + (m_rect_h >> 1), Tools.LEFT_TOP);
				g.drawImage(img_word_list[WORD_INDEX_SCJS], x + (m_rect_w >> 1), y + (m_rect_h >> 1) + h, Tools.LEFT_TOP);
				g.drawImage(img_word_list[WORD_INDEX_FH], x + (m_rect_w >> 1), y + (m_rect_h >> 1) + h * 2, Tools.LEFT_TOP);

			}
		}
	}

//	private void drawWorldMenu(Graphics g)
//	{
//		if (m_role_world) {
//			drawMsgRect(g, 150, 130, 70, (m_world_list.size() + 1) * 20);
//			// drawRect(g, 150, 130, 60, (m_world_list.size() + 1) * 20,
//			// Tools.BLACK, Tools.YELLOW, (byte) 1);
//			for (byte j = 0; j < m_world_list.size(); j++) {
//				Function func = (Function) m_world_list.elementAt(j);
//				drawColorString(g, func.m_name, 155, 132 + j * 18,
//						m_role_world_select == j ? Tools.YELLOW : Tools.WHITE, Tools.LEFT_TOP);
//			}
//			drawColorString(g, "返回", 155, 132 + m_world_list.size() * 18,
//					m_role_world_select == m_world_list.size() ? Tools.YELLOW : Tools.WHITE, Tools.LEFT_TOP);
//		}
//	}

	/**
	 * 绘制服务器界面
	 *
	 * @param g
	 */
	private void drawServerScreen(Graphics g)
	{
		drawBackground(g, 0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT, WORD_INDEX_FWQLB);
//		drawBackground2(g, X_BG, Y_BG + 40, WIDTH_BG, HEIGHT_BG - 40);

		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);

//		drawColorString(g, "选择服务器", AbstractGameScreen.SCREEN_WIDTH >> 1, 22, Tools.WHITE, Tools.HCENTER_TOP);


		// 服务器框上说明字
		Tools.drawString(g, COLOR_WORD1, COLOR_SIDE1, "服务器",  X_SERVER_BOX_SERVER + (W_SERVER_BOX_SERVER >> 1), Y_SERVER_BOX_AMOUNT - 2, Tools.HCENTER_BOTTOM);
		Tools.drawString(g, COLOR_WORD1, COLOR_SIDE1, "角色",  X_SERVER_BOX_ROLE + (W_SERVER_BOX_ROLE >> 1), Y_SERVER_BOX_AMOUNT - 2, Tools.HCENTER_BOTTOM);
		Tools.drawString(g, COLOR_WORD1, COLOR_SIDE1, "状态", X_SERVER_BOX_STATUS + (W_SERVER_BOX_STATUS >> 1), Y_SERVER_BOX_AMOUNT - 2, Tools.HCENTER_BOTTOM);
//		drawColorString(g, "服务器", X_SERVER_BOX_SERVER + (W_SERVER_BOX_SERVER >> 1), Y_SERVER_BOX_AMOUNT - 2, COLOR_WORD1, Tools.HCENTER_BOTTOM);
//		drawColorString(g, "角色", X_SERVER_BOX_ROLE + (W_SERVER_BOX_ROLE >> 1), Y_SERVER_BOX_AMOUNT - 2, COLOR_WORD1, Tools.HCENTER_BOTTOM);
//		drawColorString(g, "状态", X_SERVER_BOX_STATUS + (W_SERVER_BOX_STATUS >> 1), Y_SERVER_BOX_AMOUNT - 2, COLOR_WORD1, Tools.HCENTER_BOTTOM);
		// 框的背景
//		g.setClip(X_SERVER_BOX_AMOUNT, Y_SERVER_BOX_AMOUNT,
//				W_SERVER_BOX_AMOUNT, H_SERVER_BOX_AMOUNT);
//		for (int i = 0; i < AMOUNT_SERVER_BOX_H; i++) {
//			if (m_server_select == i) {
//				g.setColor(COLOR_BOX3);
//			}
//			else if (i % 2 == 0) {
//				g.setColor(COLOR_BOX1);
//			}
//			else {
//				g.setColor(COLOR_BOX2);
//			}
//			g.fillRect(X_SERVER_BOX_SERVER, Y_SERVER_BOX_AMOUNT + i * AbstractGameScreen.FONT_H, W_SERVER_BOX_SERVER, AbstractGameScreen.FONT_H);
//			g.fillRect(X_SERVER_BOX_ROLE, Y_SERVER_BOX_AMOUNT + i * AbstractGameScreen.FONT_H, W_SERVER_BOX_ROLE, AbstractGameScreen.FONT_H);
//			g.fillRect(X_SERVER_BOX_STATUS, Y_SERVER_BOX_AMOUNT + i * AbstractGameScreen.FONT_H, W_SERVER_BOX_STATUS, AbstractGameScreen.FONT_H);
//		}
		if (m_server_list == null) {
			return;
		}
		if (m_server_list.size() > AMOUNT_SERVER_BOX) {
			UITools.drawScrollBar(g, X_SERVER_BOX_SERVER + W_SERVER_BOX_SERVER + W_SERVER_BOX_ROLE + W_SERVER_BOX_STATUS + 2,
					Y_SERVER_BOX_AMOUNT, SERVER_BOX_H, (m_server_select + m_server_page) * 100 / (m_server_list.size() - 1));
		}
		if (m_server_list.size() > 0) {

		}
		g.setClip(X_SERVER_BOX_SERVER, Y_SERVER_BOX_AMOUNT, W_SERVER_BOX_SERVER + W_SERVER_BOX_ROLE + W_SERVER_BOX_STATUS + 2, SERVER_BOX_H);
		// 服务器框
		drawColorRect(g, X_SERVER_BOX_SERVER, Y_SERVER_BOX_AMOUNT, W_SERVER_BOX_SERVER, SERVER_BOX_H, COLOR_SIDE1, COLOR_SIDE2, COLOR_SIDE3);
		// 角色数量框
		drawColorRect(g, X_SERVER_BOX_ROLE, Y_SERVER_BOX_AMOUNT, W_SERVER_BOX_ROLE, SERVER_BOX_H, COLOR_SIDE1, COLOR_SIDE2, COLOR_SIDE3);
		// 状态框
		drawColorRect(g, X_SERVER_BOX_STATUS, Y_SERVER_BOX_AMOUNT, W_SERVER_BOX_STATUS, SERVER_BOX_H, COLOR_SIDE1, COLOR_SIDE2, COLOR_SIDE3);

		// 绘制服务器名字
		for (int i = m_server_page, y = 0; i < m_server_list.size(); i++) {
			if (i - m_server_page < AMOUNT_SERVER_BOX) {
				Function func = (Function) m_server_list.elementAt(i);
				y = Y_SERVER_BOX_AMOUNT + (i - m_server_page) * UITools.H_SINGLE_BAR + UITools.GAP_EACH_LINE;
				int color_word = COLOR_WORD1;
				if (m_server_select == i - m_server_page) {
					color_word = COLOR_WORD2;
//					g.setColor(COLOR_WORD2);
					UITools.drawSelectBox(g, X_SERVER_BOX_SERVER, y, W_SERVER_BOX_AMOUNT, UITools.H_SINGLE_BAR);
				}
				Tools.drawString(g, color_word, COLOR_SIDE1, func.m_name,  X_SERVER_BOX_SERVER + 8, y, Tools.LEFT_TOP);
				Tools.drawString(g, color_word, COLOR_SIDE1, Integer.toString(func.m_role_amount),  X_SERVER_BOX_ROLE + (W_SERVER_BOX_ROLE >> 1), y, Tools.HCENTER_TOP);
				Tools.drawString(g, color_word, COLOR_SIDE1, func.m_status == 1 ? "流畅" : "爆满", X_SERVER_BOX_STATUS + (W_SERVER_BOX_STATUS >> 1), y, Tools.HCENTER_TOP);
//				g.drawString(func.m_name, X_SERVER_BOX_SERVER + 8, y, Tools.LEFT_TOP);
//				g.drawString(Integer.toString(func.m_role_amount), X_SERVER_BOX_ROLE + (W_SERVER_BOX_ROLE >> 1), y, Tools.HCENTER_TOP);
//				g.drawString(func.m_status == 1 ? "流畅" : "爆满", X_SERVER_BOX_STATUS + (W_SERVER_BOX_STATUS >> 1), y, Tools.HCENTER_TOP);
			}
		}
//
//		for (int i = 0, y = 0; i < m_server_list.size(); i++) {
//			Function func = (Function) m_server_list.elementAt(i);
//			if (m_server_select == i) {
//				g.setColor(COLOR_WORD2);
//			} else {
//				g.setColor(COLOR_WORD1);
//			}
//			y = Y_SERVER_BOX_AMOUNT + i * single + single_side;
//			g.drawLine(X_SERVER_BOX_SERVER + 3, y + AbstractGameScreen.FONT_H + single_side, W_SERVER_BOX_SERVER + 5, y + AbstractGameScreen.FONT_H + single_side);
//			g.drawString(func.m_name, X_SERVER_BOX_SERVER + 8, y, Tools.LEFT_TOP);
//			g.drawString(Integer.toString(func.m_role_amount), X_SERVER_BOX_ROLE + (W_SERVER_BOX_ROLE >> 1), y, Tools.HCENTER_TOP);
//			g.drawString("" + func.m_status, X_SERVER_BOX_STATUS + (W_SERVER_BOX_STATUS >> 1), y, Tools.HCENTER_TOP);
//		}
//		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//		drawColorString(g, "确定", 0, AbstractGameScreen.SCREEN_HEIGHT, Tools.WHITE, Tools.LEFT_BOTTOM);
//		drawColorString(g, "退出", AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT, Tools.WHITE, Tools.RIGHT_BOTTOM);
		drawBottomButton(g, true, true);
	}

//	private int m_angle_login = 0;
	private int m_angle_create = 0;
//	private int m_angle_index = 0;// 当前最下面的下标
//	private final byte MAIN_MENU_AMOUNT = 5;

	/**
	 * 绘制用户中心主界面
	 *
	 * @param g
	 */
	private void drawMainScreen(Graphics g)
	{
//		int j = m_angle_index + 1 == MAIN_MENU_AMOUNT ? 0 : m_angle_index + 1;
//		int k = m_angle_index + 2 >= MAIN_MENU_AMOUNT ? (m_angle_index + 2) - MAIN_MENU_AMOUNT : m_angle_index + 2;
//		int m = m_angle_index - 2 < 0 ? MAIN_MENU_AMOUNT - Tools.abs(m_angle_index - 2) : m_angle_index - 2;
//		int n = m_angle_index - 1 < 0 ? MAIN_MENU_AMOUNT - 1 : m_angle_index - 1;
//
//		int y = m_main_select - 1 < 0 ? INDEX_LOGIN_COUNT - 1 : m_main_select - 1;
//		int u = m_main_select - 2 < 0 ? INDEX_LOGIN_COUNT - Tools.abs(m_main_select - 2) : m_main_select - 2;
//		int o = m_main_select + 2 >= INDEX_LOGIN_COUNT ? (m_main_select + 2) - INDEX_LOGIN_COUNT : m_main_select + 2;
//		int p = m_main_select + 1 == INDEX_LOGIN_COUNT ? 0 : m_main_select + 1;
//		for (int i = 0; i < MAIN_MENU_AMOUNT; i++) {
//			int targetX = WIDTH_SCREEN_2_1
//					- (Tools.sin(i * (360 / MAIN_MENU_AMOUNT) + m_angle_login << Tools.BITS) * 80 >> Tools.BITS);
//			int targetY = Y_MAIN_BAR
//					+ (Tools.cos(i * (360 / MAIN_MENU_AMOUNT) + m_angle_login << Tools.BITS) * 40 >> Tools.BITS);
//			g.setClip(0, Y_MAIN_BAR - 20, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT
//					- Y_MAIN_BAR + 20);
//			if (i == m_angle_index) {
//				if (m_trigger) {
//					drawMainSmallBar(g, targetX, targetY, m_main_select);
//				}
//				else {
//					drawMainBigBar(g, targetX, targetY, m_main_select);
//				}
//			}
//			else {
//				if (i == n) {
//					drawMainSmallBar(g, targetX, targetY, y);
//				}
//				else if (i == m) {
//					drawMainSmallBar(g, targetX, targetY, u);
//				}
//				else if (i == k) {
//					drawMainSmallBar(g, targetX, targetY, o);
//				}
//				else if (i == j) {
//					drawMainSmallBar(g, targetX, targetY, p);
//				}
//			}
//		}
//		if (m_test_server) {
//			if (!m_port) {
//				g.setClip(0, 0, 240, 320);
////				drawRect(g, 0, 120, 240, 20, Tools.WHITE, Tools.BLACK, (byte) (m_port_select == 0 ? -1 : 0));
////				drawRect(g, 0, 140, 240, 20, Tools.WHITE, Tools.BLACK, (byte) (m_port_select == 1 ? -1 : 0));
////				drawRect(g, 0, 160, 240, 20, Tools.WHITE, Tools.BLACK, (byte) (m_port_select == 2 ? -1 : 0));
////				drawRect(g, 0, 180, 240, 20, Tools.WHITE, Tools.BLACK, (byte) (m_port_select == 3 ? -1 : 0));
////				drawRect(g, 0, 200, 240, 20, Tools.WHITE, Tools.BLACK, (byte) (m_port_select == 4 ? -1 : 0));
////				drawRect(g, 0, 220, 240, 20, Tools.WHITE, Tools.BLACK, (byte) (m_port_select == 5 ? -1 : 0));
////				drawRect(g, 0, 240, 240, 20, Tools.WHITE, Tools.BLACK, (byte) (m_port_select == 6 ? -1 : 0));
////				drawColorString(g, "192.2.9.191 : 2819", 120, 122, m_port_select == 0 ? Tools.WHITE : Tools.BLACK, Tools.HCENTER_TOP);
////				drawColorString(g, "192.2.9.191 : 7711", 120, 142, m_port_select == 1 ? Tools.WHITE : Tools.BLACK, Tools.HCENTER_TOP);
////				drawColorString(g, "192.2.9.191 : 2888", 120, 162, m_port_select == 2 ? Tools.WHITE : Tools.BLACK, Tools.HCENTER_TOP);
////				drawColorString(g, "106.3.241.131:1928", 120, 182, m_port_select == 3 ? Tools.WHITE : Tools.BLACK, Tools.HCENTER_TOP);
////				drawColorString(g, "192.2.9.191 : 8888", 120, 202, m_port_select == 4 ? Tools.WHITE : Tools.BLACK, Tools.HCENTER_TOP);
////				drawColorString(g, "192.2.9.191 : 2817", 120, 222, m_port_select == 5 ? Tools.WHITE : Tools.BLACK, Tools.HCENTER_TOP);
////				drawColorString(g, "192.2.9.191 : 1928", 120, 242, m_port_select == 6 ? Tools.WHITE : Tools.BLACK, Tools.HCENTER_TOP);
//
//				int ty = (AbstractGameScreen.SCREEN_HEIGHT - SERVER_LIST_IP.length * 20) >> 1;
//				for (int i = 0; i < SERVER_LIST_IP.length; i++) {
//					drawRect(g, 0, ty + i * 20, 240, 20, Tools.WHITE, Tools.BLACK, (byte) (m_port_select == i ? -1 : 0));
//					drawColorString(g, SERVER_LIST_IP[i] + " : " + SERVER_LIST_PORT[i],
//							120, ty + 2 + i * 20, m_port_select == i ? Tools.WHITE : Tools.BLACK, Tools.HCENTER_TOP);
//				}
//			}
//		}
		int screen_10_1 = AbstractGameScreen.SCREEN_HEIGHT / 11;
		// 绘制快速注册
		if (m_main_select == INDEX_LOGIN_KSZC) {
			g.drawImage(img_bar_big, AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 7, Tools.HCENTER_TOP);
			g.drawImage(img_word_list[WORD_INDEX_KSJR], AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 7 + 3, Tools.HCENTER_TOP);
		} else {
			g.drawImage(img_bar_small, AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 7, Tools.HCENTER_TOP);
			g.drawImage(img_word_list[WORD_INDEX_KSJR], AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 7, Tools.HCENTER_TOP);
		}
		// 绘制账号注册
		if (m_main_select == INDEX_LOGIN_ZHZC) {
			g.drawImage(img_bar_big, AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 8, Tools.HCENTER_TOP);
			g.drawImage(img_word_list[WORD_INDEX_ZHZC], AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 8 + 3, Tools.HCENTER_TOP);
		} else {
			g.drawImage(img_bar_small, AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 8, Tools.HCENTER_TOP);
			g.drawImage(img_word_list[WORD_INDEX_ZHZC], AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 8, Tools.HCENTER_TOP);
		}
		// 绘制登录游戏
		if (m_main_select == INDEX_LOGIN_DLYX) {
			g.drawImage(img_bar_big, AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 9, Tools.HCENTER_TOP);
			g.drawImage(img_word_list[WORD_INDEX_DLYX], AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 9 + 3, Tools.HCENTER_TOP);
		} else {
			g.drawImage(img_bar_small, AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 9, Tools.HCENTER_TOP);
			g.drawImage(img_word_list[WORD_INDEX_DLYX], AbstractGameScreen.SCREEN_WIDTH >> 1, screen_10_1 * 9, Tools.HCENTER_TOP);
		}


//		Tools.drawString(g, Tools.WHITE, Tools.BLACK, "当前版本 : " + PACKAGE_VERSION, 0, 0, Tools.LEFT_TOP);
		drawBottomButton(g, true, true);
//		UITools.drawWindowSoftkey(g, "确定", "返回", 0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
	}

//	private void drawMainBigBar(Graphics g, int x, int y, int index)
//	{
//		// 大的
//		g.drawImage(img_bar_big, x, y, Tools.HCENTER_VCENTER);
//		g.drawImage(img_word[index + (img_word.length >> 1)], x, y - 2, Tools.HCENTER_VCENTER);
//	}

//	private void drawMainSmallBar(Graphics g, int x, int y, int index)
//	{
//		g.drawImage(img_bar_small, x, y, Tools.HCENTER_VCENTER);
//		g.drawImage(img_word[index], x, y, Tools.HCENTER_VCENTER);
//	}

	private boolean m_trigger = false;// 是否在切换中
//	private final int Y_MAIN_BAR = AbstractGameScreen.SCREEN_HEIGHT - 60;
//	private void drawButton(Graphics g, int x, int y, int w, boolean showCorner, boolean select)
//	{
//		int bw = img_user[IMG_INDEX_AN_BAR1].getWidth();// 条
//		int bh = img_user[IMG_INDEX_AN_BAR1].getHeight();
//		int cw = img_user[IMG_INDEX_AN_CORNER].getWidth();// 角
//		int ch = img_user[IMG_INDEX_AN_CORNER].getHeight();
//		int dv = (ch - bh + 1) >> 1;// 角和条的高度差值
//		int rw = w - (cw << 1);
//		g.setClip(x + cw, y, rw, ch);
//		Image img;
//		if (select) {
//			img = img_user[IMG_INDEX_AN_BAR2];
//		}
//		else {
//			img = img_user[IMG_INDEX_AN_BAR1];
//		}
//		if (showCorner) {
//			for (int i = cw; i <= rw + bw; i += bw) {
//				g.drawImage(img, x + i, y + dv, Tools.LEFT_TOP);
//			}
//		}
//		else {
//			for (int i = 0; i <= w + bw; i += bw) {
//				g.drawImage(img, x + i, y + dv, Tools.LEFT_TOP);
//			}
//		}
//		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH,
//				AbstractGameScreen.SCREEN_HEIGHT);
//		if (showCorner) {
//			g.drawImage(img_user[IMG_INDEX_AN_CORNER], x, y, Tools.LEFT_TOP);
//			Tools.drawRegion(g, img_user[IMG_INDEX_AN_CORNER], x + cw + rw, y,
//					Tools.TRANS_H, Tools.LEFT_TOP);
//		}
//	}

//	private void drawBackground3(Graphics g, int x, int y, int w, int h)
//	{
//		int cw = img_user[IMG_INDEX_CORNER2].getWidth();
//		int ch = img_user[IMG_INDEX_CORNER2].getHeight();
//		// 上边
//		drawColorLine(g, x + cw, y, x + w - cw, y, 0);
//		// 下边
//		drawColorLine(g, x + cw, y + h, x + w - cw, y + h, 1);
//		// 左边
//		drawColorLine(g, x, y + ch, x, y + h - ch, 2);
//		// 右边
//		drawColorLine(g, x + w, y + ch, x + w, y + h - ch, 3);
//		// 左上角
//		g.drawImage(img_user[IMG_INDEX_CORNER2], x, y, Tools.LEFT_TOP);
//		// 右上角
//		Tools.drawRegion(g, img_user[IMG_INDEX_CORNER2], x + w + 1, y,
//				Tools.TRANS_H, Tools.RIGHT_TOP);
//		// 左下角
//		Tools.drawRegion(g, img_user[IMG_INDEX_CORNER2], x, y + h + 1,
//				Tools.TRANS_V, Tools.LEFT_BOTTOM);
//		// 右下角
//		Tools.drawRegion(g, img_user[IMG_INDEX_CORNER2], x + w + 1, y + h + 1,
//				Tools.TRANS_HV, Tools.RIGHT_BOTTOM);
//	}

	private void drawBackground(Graphics g, int x, int y, int w, int h, int index)
	{
		// img_user[IMG_INDEX_AN_BAR1]//上边条
		// img_user[IMG_INDEX_CORNER3]//上角
		// img_user[IMG_INDEX_ABG1]//背景
		// 背景
//		int bw = img_user[IMG_INDEX_ABG1].getWidth();
//		int bh = img_user[IMG_INDEX_ABG1].getHeight();
//		g.setClip(x, y, w, h);
//		for (int i = 0, j = 0; i <= w; i += bw) {
//			for (j = 0; j <= h; j += bh) {
//				g.drawImage(img_user[IMG_INDEX_ABG1], x + i, y + j, Tools.LEFT_TOP);
//			}
//		}
		//#if lucency == "YES"
		UITools.drawFillRectAlpha(g, x, y, w, h, 0x993B2415);
		//#endif

		// bw = img_user[IMG_INDEX_AN_BAR1].getWidth();
		// bh = img_user[IMG_INDEX_AN_BAR1].getHeight();
		// 边框
		// drawColorRect(g, x, y + bh, w, h - bh, 0x580d00, 0xfffeda, 0x230200);

//		// 上边条
//		for (int i = 0; i <= w; i += bw) {
//			g.drawImage(img_user[IMG_INDEX_AN_BAR1], x + i, y, Tools.LEFT_TOP);
//		}
//		// 上两边角
//		g.drawImage(img_user[IMG_INDEX_CORNER3], x, y, Tools.LEFT_TOP);
//		Tools.drawRegion(g, img_user[IMG_INDEX_CORNER3], x + w, y,
//				Tools.TRANS_H, Tools.RIGHT_TOP);
		drawTitle(g, index, x, y, w, h);

	}
	public final void drawTitle(Graphics g, int index, int x, int y, int w, int h)
	{
		g.setClip(x, y, w, h);
		int midLen = w - (UIManager.IMAGE_TITlE_SMALL.getWidth() << 1);
		if (midLen > 0) {
			int midAmount = midLen / UIManager.IMAGE_TITlE_MIDDLE.getWidth() + 1;
			for (int i = 0; i < midAmount; i++) {
				g.drawImage(UIManager.IMAGE_TITlE_MIDDLE, x + UIManager.IMAGE_TITlE_SMALL.getWidth() + i
						* UIManager.IMAGE_TITlE_MIDDLE.getWidth(),
						y, Tools.LEFT_TOP);
			}
		}
		g.drawImage(UIManager.IMAGE_TITlE_SMALL, x, y, Tools.LEFT_TOP);
		Tools.drawRegion(g, UIManager.IMAGE_TITlE_SMALL, x + w - UIManager.IMAGE_TITlE_SMALL.getWidth(), y,
				Tools.TRANS_H, Tools.LEFT_TOP);
		if (img_word_list != null && index < img_word_list.length && img_word_list[index] != null) {
			g.drawImage(img_word_list[index], x + (w >> 1), y + (UIManager.IMAGE_TITlE_SMALL.getHeight() >> 1), Tools.HCENTER_VCENTER);
		}
	}
//	private void drawBackground2(Graphics g, int x, int y, int w, int h) {
//		// 背景
//		// int bw = img_user[IMG_INDEX_ABG1].getWidth();
//		// int bh = img_user[IMG_INDEX_ABG1].getHeight();
//		// g.setClip(x, y, w, h);
//		// for (int i = 0, j = 0; i <= w; i += bw) {
//		// for (j = 0; j <= h; j += bh) {
//		// g.drawImage(img_user[IMG_INDEX_ABG1], x + i, y + j, Tools.LEFT_TOP);
//		// }
//		// }
//		// 边框
//		drawColorRect(g, x, y, w, h, 0x580d00, 0xfffeda, 0x230200);
//		// 左上角
//		g.drawImage(img_user[IMG_INDEX_CORNER1], x + 2, y + 2, Tools.LEFT_TOP);
//		// 右上角
//		Tools.drawRegion(g, img_user[IMG_INDEX_CORNER1], x + w - 2, y + 2, Tools.TRANS_H, Tools.RIGHT_TOP);
//		// 左下角
//		Tools.drawRegion(g, img_user[IMG_INDEX_CORNER1], x + 2, y + h, Tools.TRANS_V, Tools.LEFT_BOTTOM);
//		// 右下角
//		Tools.drawRegion(g, img_user[IMG_INDEX_CORNER1], x + w - 2, y + h, Tools.TRANS_HV, Tools.RIGHT_BOTTOM);
//	}

	private void drawColorRect(Graphics g, int x, int y, int w, int h,
			int color1, int color2, int color3)
	{
		g.setColor(color1);// 外
		g.drawRect(x, y, w - 1, h - 1);
		g.setColor(color2);// 中
		g.drawRect(x + 1, y + 1, w - 3, h - 3);
		g.setColor(color3);// 内
		g.drawRect(x + 2, y + 2, w - 5, h - 5);
	}

	private void drawMsgRect(Graphics g, int x, int y, int w, int h)
	{
		g.setColor(0x3A2010);
		g.fillRect(x, y, w, h);
		drawColorRect(g, x, y, w, h, 0x020000, 0xd0d08c, 0x3A2010);
	}

//	private void drawColorLine(Graphics g, int sx, int sy, int ex, int ey,
//			int type)
//	{
//		g.setColor(0x580d00);// 外
//		g.drawLine(sx, sy, ex, ey);
//		switch (type) {
//			case 0:// 上
//				g.setColor(0xfffeda);// 中
//				g.drawLine(sx, sy + 1, ex, ey + 1);
//				g.setColor(0x230200);// 内
//				g.drawLine(sx, sy + 2, ex, ey + 2);
//				break;
//			case 1:// 下
//				g.setColor(0xfffeda);// 中
//				g.drawLine(sx, sy - 1, ex, ey - 1);
//				g.setColor(0x230200);// 内
//				g.drawLine(sx, sy - 2, ex, ey - 2);
//				break;
//			case 2:// 左
//				g.setColor(0xfffeda);// 中
//				g.drawLine(sx + 1, sy, ex + 1, ey);
//				g.setColor(0x230200);// 内
//				g.drawLine(sx + 2, sy, ex + 2, ey);
//				break;
//			case 3:// 右
//				g.setColor(0xfffeda);// 中
//				g.drawLine(sx - 1, sy, ex - 1, ey);
//				g.setColor(0x230200);// 内
//				g.drawLine(sx - 2, sy, ex - 2, ey);
//				break;
//		}
//	}

//	/**
//	 * 绘制快速注册界面
//	 *
//	 * @param g
//	 */
//	private void drawQuickScreen(Graphics g)
//	{
//		drawColorString(g, "账号注册", AbstractGameScreen.SCREEN_WIDTH >> 1, 20, 0,
//				Tools.HCENTER_TOP);
//		for (int i = 0; i < QUICK_BOX_PROPERTY.length; i++) {
//			drawRect(g, QUICK_BOX_PROPERTY[i][0], QUICK_BOX_PROPERTY[i][1],
//					QUICK_BOX_PROPERTY[i][2], QUICK_BOX_PROPERTY[i][3],
//					Tools.BLACK, Tools.YELLOW, (byte) (m_quick_select == i ? -1
//							: 1));
//		}
//		for (int i = 0; i < QUICK_BOX_CHARS.length; i++) {
//			if (i > 1) {
//				drawColorString(g, QUICK_BOX_CHARS[i], 5,
//						QUICK_BOX_PROPERTY[i + 1][1] + 1, Tools.WHITE,
//						Tools.LEFT_TOP);
//				if (m_quick_select == i + 1) {
//					drawColorString(g, m_quick_box_content[i],
//							QUICK_BOX_PROPERTY[i + 1][0] + 1,
//							QUICK_BOX_PROPERTY[i + 1][1] + 1, Tools.BLACK,
//							Tools.LEFT_TOP);
//				}
//				else {
//					drawColorString(g, m_quick_box_content[i],
//							QUICK_BOX_PROPERTY[i + 1][0] + 1,
//							QUICK_BOX_PROPERTY[i + 1][1] + 1, Tools.WHITE,
//							Tools.LEFT_TOP);
//				}
//			}
//			else {
//				drawColorString(g, QUICK_BOX_CHARS[i], 5,
//						QUICK_BOX_PROPERTY[i][1] + 1, Tools.WHITE,
//						Tools.LEFT_TOP);
//				if (m_quick_select == i) {
//					drawColorString(g, m_quick_box_content[i],
//							QUICK_BOX_PROPERTY[i][0] + 1,
//							QUICK_BOX_PROPERTY[i][1] + 1, Tools.BLACK,
//							Tools.LEFT_TOP);
//				}
//				else {
//					drawColorString(g, m_quick_box_content[i],
//							QUICK_BOX_PROPERTY[i][0] + 1,
//							QUICK_BOX_PROPERTY[i][1] + 1, Tools.WHITE,
//							Tools.LEFT_TOP);
//				}
//			}
//		}
//		if (m_quick_select != 2 && m_quick_select != 6) {
//			if (m_quick_select > 1) {
//				drawInputChars(
//						g,
//						AbstractGameScreen.s_font
//								.stringWidth(m_quick_box_content[m_quick_select - 1])
//								+ QUICK_BOX_PROPERTY[m_quick_select][0] + 1,
//						QUICK_BOX_PROPERTY[m_quick_select][1] + 1, Tools.BLACK);
//			}
//			else {
//				drawInputChars(
//						g,
//						AbstractGameScreen.s_font
//								.stringWidth(m_quick_box_content[m_quick_select])
//								+ QUICK_BOX_PROPERTY[m_quick_select][0] + 1,
//						QUICK_BOX_PROPERTY[m_quick_select][1] + 1, Tools.BLACK);
//			}
//		}
//	}
	private static Image mexit1, mexit2;
    public static void paintExit(Graphics g, int progress) {
        g.setClip(0, 0, 480, 320);
        if (progress == 1) {
            if (mexit1 == null) {
                try {
                    mexit1 = Image.createImage("/exit1.png");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (mexit1 != null)
                g.drawImage(mexit1, 0, 0, Graphics.LEFT|Graphics.TOP);
        } else if (progress == 2) {
            if (mexit2 == null) {
                try {
                    mexit2 = Image.createImage("/exit2.png");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (mexit2 != null)
                g.drawImage(mexit2, 0, 0, Graphics.LEFT|Graphics.TOP);
        }
    }
	/**
	 * 绘制登录游戏界面
	 *
	 * @param g
	 */
	private void drawLoginScreen(Graphics g)
	{
	       if (exit_progress > 0) {//日本人
	            paintExit(g, exit_progress);
	            return;
	        }
		drawBackground(g, 0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT, WORD_INDEX_DL);
		// drawBackground2(g, X_BG, Y_BG + 40, WIDTH_BG, HEIGHT_BG - 40);

//		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
//		drawColorString(g, "登录游戏", AbstractGameScreen.SCREEN_WIDTH >> 1, 2, Tools.WHITE, Tools.HCENTER_TOP);
//		for (int i = 0, x, y, w, h; i < LOGIN_BOX_PROPERTY.length; i++) {
//			x = LOGIN_BOX_PROPERTY[i][0];
//			y = LOGIN_BOX_PROPERTY[i][1];
//			w = LOGIN_BOX_PROPERTY[i][2];
//			h = LOGIN_BOX_PROPERTY[i][3];
//			if (img_word_list != null && LOGIN_BOX_WORD[i] < img_word_list.length) {
//				img = img_word_list[];
//			}
//			if (img != null) {
//				if (i < 2) {// 画框
//					drawMsgRect(g, x + 20, y, w, h, 0x020000, 0xd0d08c, 0x0c3236);// 账号密码输入背景框
//					drawMsgRect(g, x - img.getWidth() - 5, y - 1,
//							img.getWidth() + 20, AbstractGameScreen.FONT_H + 6, 0xDDDDA0, 0xDDDDA0, 0x502A2A);// 账号 密码框
//					drawColorString(g, word, x - getStringWidth(word) + 5, y + 2, 0xF8EC89, Tools.LEFT_TOP);
//					drawRectByWord(g, x, y, w, h, index)
//					if (m_login_select == i) {
//						drawColorRect(g, x + 18, y - 2, w + 4, h + 4, 0x550a00, 0xf3fd76, 0xf3fd76);
//					}
//				}
//				else if (i == 2) {// 画选择按钮
//					g.drawImage(img_user[IMG_INDEX_CHOOSE_BG], x
//							+ (img_user[IMG_INDEX_CHOOSE_BG].getWidth() >> 1), y
//							+ (img_user[IMG_INDEX_CHOOSE_BG].getHeight() >> 1),
//							Tools.HCENTER_VCENTER);
//					if (m_login_select == i) {
//						drawColorRect(g, x - 2, y - 2,
//								img_user[IMG_INDEX_CHOOSE_BG].getWidth() + 4,
//								img_user[IMG_INDEX_CHOOSE_BG].getHeight() + 4,
//								0x550a00, 0xf3fd76, 0xf3fd76);
//					}
//					if (m_save_name) {
//						g.drawImage(
//								img_user[IMG_INDEX_CHOOSE_CN],
//								x + (img_user[IMG_INDEX_CHOOSE_BG].getWidth() >> 1),
//								y + (img_user[IMG_INDEX_CHOOSE_BG].getHeight() >> 1),
//								Tools.HCENTER_VCENTER);
//					}
//					drawColorString(g, word,
//							x + img_user[IMG_INDEX_CHOOSE_BG].getWidth() + 10, y,
//							0xF8EC89, Tools.LEFT_TOP);
//				}
//				else {// 画按钮
//					drawButton(g, x, y, w, true, m_login_select == i ? true : false);
//					drawColorString(g, word, x + (w >> 1), y + 2, 0xF8EC89,
//							Tools.HCENTER_TOP);
//				}
//			}
//		}
//		drawMsgRect(g, X_MSG, Y_MSG, WIDTH_MSG, HEIGHT_MSG, 0x020000, 0xd0d08c, 0x0c3236);
		// if (m_login_select == 0) {
		// drawColorRect(g, X_NAME - 2, Y_NAME - 2, 150 + 4,
		// AbstractGameScreen.FONT_H + 4, 0x550a00, 0xf3fd76, 0xf3fd76);
		// } else if (m_login_select == 1) {
		// drawColorRect(g, X_NAME - 2, Y_PASSWORD - 2, 150 + 4,
		// AbstractGameScreen.FONT_H + 4, 0x550a00, 0xf3fd76, 0xf3fd76);
		// } else {
		// int[] point = LOGIN_BOX_PROPERTY[m_login_select];
		// g.setColor(Tools.BLACK);
		// g.drawRect(point[0], point[1], point[2], point[3]);
		//
		// drawRect(g, X_NAME, Y_NAME, 150, AbstractGameScreen.FONT_H,
		// Tools.BLACK, Tools.YELLOW, (byte)1);
		// drawRect(g, X_NAME, Y_PASSWORD, 150, AbstractGameScreen.FONT_H,
		// Tools.BLACK, Tools.YELLOW, (byte)1);
		// }
		// //名字和密码底背景框
		// drawMsgRect(g, X_NAME, Y_NAME, 150, AbstractGameScreen.FONT_H,
		// 0x020000, 0xd0d08c, 0x0c3236);
		// drawMsgRect(g, X_NAME, Y_PASSWORD, 150, AbstractGameScreen.FONT_H,
		// 0x020000, 0xd0d08c, 0x0c3236);

		if (img_word_list == null) {
			return;
		}
//		int screen_h_10_1 = AbstractGameScreen.SCREEN_HEIGHT / 10;
//		int screen_w_10_1 = AbstractGameScreen.SCREEN_WIDTH / 10;

		int x = 0, y = 0;
		Image img = img_word_list[WORD_INDEX_ZH];
		// 绘制账号
		if (img != null) {
			x = W_SCREEN_N_1 * 1 + img.getWidth() + m_rect_w + 10;
			y = H_SCREEN_N_1 * 2 + O_SCREEN;
			drawRectByWord(g, W_SCREEN_N_1 * 1, y, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_ZH, true);
			if (m_login_select == LOGIN_INDEX_ZH) {
				g.setColor(0x3A2010);
				g.drawRect(x - 3, y - 3, WIDTH_SCREEN_4_1 * 2 + 6, img.getHeight() + m_rect_h + 6);
				g.setColor(0xF5FB7C);
				g.fillRect(x - 2, y - 2, WIDTH_SCREEN_4_1 * 2 + 5, img.getHeight() + m_rect_h + 5);
			}
			g.setColor(0x3A2010);
			g.fillRect(x, y, WIDTH_SCREEN_4_1 * 2, img.getHeight() + m_rect_h);
			g.setColor(0xebeb8b);
			g.drawRect(x, y, WIDTH_SCREEN_4_1 * 2, img.getHeight() + m_rect_h);

			if (m_login_name != null) {
				drawColorString(g, m_login_name, x + 6, y + ((img.getHeight() + m_rect_h - AbstractGameScreen.FONT_H) >> 1), Tools.WHITE, Tools.LEFT_TOP);
			}

		}
		// 绘制密码
		img = img_word_list[WORD_INDEX_MM];
		if (img != null) {
			x = W_SCREEN_N_1 * 1 + img.getWidth() + m_rect_w + 10;
			y = H_SCREEN_N_1 * 3 + O_SCREEN;
			drawRectByWord(g, W_SCREEN_N_1 * 1, y, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_MM, true);
			if (m_login_select == LOGIN_INDEX_MM) {
				g.setColor(0x3A2010);
				g.drawRect(x - 3, y - 3, WIDTH_SCREEN_4_1 * 2 + 6, img.getHeight() + m_rect_h + 6);
				g.setColor(0xF5FB7C);
				g.fillRect(x - 2, y - 2, WIDTH_SCREEN_4_1 * 2 + 5, img.getHeight() + m_rect_h + 5);
			}
			g.setColor(0x3A2010);
			g.fillRect(x, y, WIDTH_SCREEN_4_1 * 2, img.getHeight() + m_rect_h);
			g.setColor(0xebeb8b);
			g.drawRect(x, y, WIDTH_SCREEN_4_1 * 2, img.getHeight() + m_rect_h);
			if (m_login_password != null) {
				if (m_login_password != null && !m_login_password.equals("")) {
				String temp = "";
				for (int i = 0; i < m_login_password.length(); i++) {
					temp += "*";
				}
				drawColorString(g, temp, x + 6, y + 2 + ((img.getHeight() + m_rect_h - AbstractGameScreen.FONT_H) >> 1), Tools.WHITE, Tools.LEFT_TOP);
			}
			}
		}
		// 绘制保存账号和密码
		img = img_word_list[WORD_INDEX_JZZHJMM];
		if (img != null) {
			x = WIDTH_SCREEN_2_1 - 10 - (img.getWidth() >> 1);
			y = H_SCREEN_N_1 * 4 + m_rect_h + O_SCREEN;
			if (m_login_select == LOGIN_INDEX_JZZHJMM) {
				g.setColor(0x3A2010);
				g.drawRect(x - 2 - (img_choose_bg.getWidth() >> 1), y - 2 - (img_choose_bg.getHeight() >> 1),
						img_choose_bg.getWidth() + 3, img_choose_bg.getHeight() + 3);
				g.setColor(0xF5FB7C);
				g.fillRect(x - 1 - (img_choose_bg.getWidth() >> 1), y - 1 - (img_choose_bg.getHeight() >> 1),
						img_choose_bg.getWidth() + 2, img_choose_bg.getHeight() + 2);
			}
			g.drawImage(img, WIDTH_SCREEN_2_1, y, Tools.HCENTER_VCENTER);
			if (img_choose_bg != null) {
				g.drawImage(img_choose_bg, x, y, Tools.HCENTER_VCENTER);
				if (m_save_name && img_choose_cn != null) {
					g.drawImage(img_choose_cn, x, y, Tools.HCENTER_VCENTER);
				}
			}
		}
		// 绘制快速进入，谢亮
		if (mquick == null) {
			try {
				mquick = Image.createImage("/quick.png");
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
//		285,158,72,25
		if (mquick != null) {
			g.drawImage(mquick, 285, H_SCREEN_N_1 * 5 + O_SCREEN, Tools.LEFT_TOP);
		}
		// 绘制登录游戏
		img = img_word_list[WORD_INDEX_DLYX];
		if (img != null) {
//			if (m_login_select == LOGIN_INDEX_DLYX) {
//				drawRectByWord(g, WIDTH_SCREEN_2_1 - ((img.getWidth() + m_rect_w) >> 1),
//						H_SCREEN_N_1 * 5 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_DLYX, true);
//			} else {
				drawRectByWord(g, WIDTH_SCREEN_3_1 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 5 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_DLYX, true);
//			}
		}
		// 绘制账号注册
		img = img_word_list[WORD_INDEX_ZHZC];
		if (img != null) {
			if (m_login_select == LOGIN_INDEX_ZHZC) {
				drawRectByWord(g, WIDTH_SCREEN_3_1 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 6 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_ZHZC, true);
			} else {
				drawRectByWord(g, WIDTH_SCREEN_3_1 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 6 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_ZHZC, true);
			}
		}
		// 绘制账号管理
		img = img_word_list[WORD_INDEX_ZHGL];
		if (img != null) {
			if (m_login_select == LOGIN_INDEX_ZHGL) {
				drawRectByWord(g, WIDTH_SCREEN_3_2 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 6 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_ZHGL, true);
			} else {
				drawRectByWord(g, WIDTH_SCREEN_3_2 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 6 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_ZHGL, true);
			}
		}
		// 绘制游戏设置
		img = img_word_list[WORD_INDEX_YXSZ];
		if (img != null) {

			if (m_login_select == LOGIN_INDEX_YXSZ) {
				drawRectByWord(g, WIDTH_SCREEN_3_1 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 7 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_YXSZ, true);
			} else {
				drawRectByWord(g, WIDTH_SCREEN_3_1 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 7 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_YXSZ, true);
			}
		}
		// 绘制游戏帮助
		img = img_word_list[WORD_INDEX_YXBZ];
		if (img != null) {

			if (m_login_select == LOGIN_INDEX_YXBZ) {
				drawRectByWord(g, WIDTH_SCREEN_3_2 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 7 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_YXBZ, true);
			} else {
				drawRectByWord(g, WIDTH_SCREEN_3_2 - ((img.getWidth() + m_rect_w) >> 1),
						H_SCREEN_N_1 * 7 + O_SCREEN, img.getWidth() + m_rect_w, img.getHeight() + m_rect_h, WORD_INDEX_YXBZ, true);
			}
		}

		// 名字和密码字
//		drawColorString(g, m_login_name, X_NAME + 5 + 20, Y_NAME + 3, Tools.WHITE, Tools.LEFT_TOP);
//		if (m_login_password != null && !m_login_password.equals("")) {
//			String temp = "";
//			for (int i = 0; i < m_login_password.length(); i++) {
//				temp += "*";
//			}
//			drawColorString(g, temp, X_NAME + 5 + 20, Y_PASSWORD + 3, Tools.WHITE, Tools.LEFT_TOP);
//		}
//		 {124,258,72,25},//日本人
//         {285,258,72,25},
	      if (mmoregame == null) {
	            try {
	                mmoregame = Image.createImage("/moregame.png");
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	        }
	        if (mmoregame != null) {
	            g.drawImage(mmoregame, 126, 258, Graphics.LEFT|Graphics.TOP);
	        }
	        if (mabout == null) {
                try {
                    mabout = Image.createImage("/about.png");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (mabout != null) {
                g.drawImage(mabout, 286, 258, Graphics.LEFT|Graphics.TOP);
            }
		drawBottomButton(g, true, true);
	}
	private Image mmoregame, mabout, mquick;

	private int m_rect_w = 20;
	private int m_rect_h = 10;

	private void drawBottomButton(Graphics g, boolean left, boolean right) {
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		if (left) {
			drawRectByWord(g, 0, AbstractGameScreen.SCREEN_HEIGHT - SOFTKEY_H - 1, SOFTKEY_W, SOFTKEY_H, WORD_INDEX_QD, true);
		}

		if (right) {
			drawRectByWord(g, AbstractGameScreen.SCREEN_WIDTH - SOFTKEY_W - 1,
					AbstractGameScreen.SCREEN_HEIGHT - SOFTKEY_H - 1, SOFTKEY_W, SOFTKEY_H, WORD_INDEX_TC, true);
		}
	}

	/**
	 * 绘制帮助关于界面
	 *
	 * @param g
	 */
	private void drawHelpScreen(Graphics g)
	{

	}

	/**
	 * 绘制游戏设置界面
	 *
	 * @param g
	 */
	private void drawSetScreen(Graphics g)
	{

	}

	/**
	 * 绘制方框
	 *
	 * @param g
	 * 画笔
	 * @param x
	 * 横向起始点
	 * @param y
	 * 纵向起始点
	 * @param w
	 * 方框宽度
	 * @param h
	 * 方框高度
	 * @param bcolor
	 * 方框底色
	 * @param scolor
	 * 方框边色
	 * @param type
	 * 方框类型 小于零为被选中, 大于零为不被选中
	 */
	private void drawRect(Graphics g, int x, int y, int w, int h, int bcolor, int scolor, byte type)
	{
		int obcolor = 0xFFFFFF - bcolor;
		int oscolor = 0xFFFFFF - scolor;
		if (type < 0) {
			g.setColor(obcolor);
			g.fillRect(x, y, w, h);
			g.setColor(oscolor);
			g.drawRect(x, y, w - 1, h - 1);
		}
		else {
			g.setColor(bcolor);
			g.fillRect(x, y, w, h);
			g.setColor(scolor);
			g.drawRect(x, y, w - 1, h - 1);
		}
	}

	/**
	 * 接收选择人物返回信息
	 *
	 * @param type
	 * @param body
	 */
	private void recvSelectRoleMessage(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("选择人物返回信息!");
		byte state = dis.readByte();// 状态 0失败,1成功
		Tools.debugPrintln("状态 : " + state);
		if (state == 1) {
			dis.readLong();//id
			GameManager.getInstance().m_game_message.sendUserSelectWorld(0);
			// GameManager.getInstance().m_role.m_name = dis.readUTF();//名字
			// Tools.debugPrintln("名字 : " +
			// GameManager.getInstance().m_role.m_name);
			// GameManager.getInstance().m_role.m_sex = dis.readByte();//性别
			// Tools.debugPrintln("性别 : " +
			// GameManager.getInstance().m_role.m_sex);
			// GameManager.getInstance().m_role.m_career = dis.readByte();//职业
			// Tools.debugPrintln("职业 : " +
			// GameManager.getInstance().m_role.m_career);
			// GameManager.getInstance().m_role.m_race = dis.readByte();//种族
			// Tools.debugPrintln("种族 : " +
			// GameManager.getInstance().m_role.m_race);
			// GameManager.getInstance().m_role.m_lv = dis.readInt();// 等级
			// Tools.debugPrintln("等级 : " +
			// GameManager.getInstance().m_role.m_lv);
			// GameManager.getInstance().m_role.m_hpMax = dis.readInt();//
			// 当前最大HP
			// Tools.debugPrintln("当前最大HP : " +
			// GameManager.getInstance().m_role.m_hpMax);
			// GameManager.getInstance().m_role.m_hp = dis.readInt();// 当前HP
			// Tools.debugPrintln("当前HP : " +
			// GameManager.getInstance().m_role.m_hp);
			// GameManager.getInstance().m_role.m_mpMax = dis.readInt();//
			// 当前最大MP
			// Tools.debugPrintln("当前最大MP : " +
			// GameManager.getInstance().m_role.m_mpMax);
			// GameManager.getInstance().m_role.m_mp = dis.readInt();// 当前MP
			// Tools.debugPrintln("当前MP : " +
			// GameManager.getInstance().m_role.m_mp);
			// GameManager.getInstance().m_role.m_faction =
			// (GameManager.getInstance().m_role.m_race - 1) / 2 + 1;
			// GameManager.getInstance().m_roleResList.clean();
			//
			// int resCount = dis.readByte();
			// // int resCount = 1;
			// //
			// ResHead[] heads = new ResHead[resCount];
			//
			// // 角色的m_anims和m_refsResHead固定大小为2。。。分别对应0时装和1武器
			// GameManager.getInstance().m_role.m_anims = new Animation[2];
			// GameManager.getInstance().m_role.m_refsResHead = new ResHead[2];
			// Tools.debugPrintln("资源数量 : " + resCount);
			// int animCounter = 0;
			// for (int i = 0; i < resCount; i++) {
			// // String resURL = dis.readUTF();
			// // Tools.debugPrintln("资源URL : " + resURL);
			// // heads[i] = new ResHead(ObjectAdapter.RESOURCE_TYPE_ANIM,
			// resURL, 1);
			// heads[i] = new ResHead(dis.readByte(), dis.readUTF(),
			// dis.readInt());
			// GameManager.getInstance().m_roleResList.put(heads[i]);
			// Tools.debugPrintln("资源URL : " + heads[i].m_url);
			// if (heads[i].m_type == ObjectAdapter.RESOURCE_TYPE_ANIM) {
			// GameManager.getInstance().m_role.m_refsResHead[animCounter] =
			// heads[i];
			// GameManager.getInstance().m_role.m_anims[animCounter++] =
			// (Animation) (ResourceManager.getInstance().loadResource(
			// GameManager.getInstance().m_resource_scene, heads[i]));
			// } else {
			// ResourceManager.getInstance().loadResource(
			// GameManager.getInstance().m_resource_scene, heads[i]);
			// }
			// }
			// GameManager.getInstance().m_role.m_anim =
			// GameManager.getInstance().m_role.m_anims[0];
			// GameManager.getInstance().m_role.m_needSendPath = true;
			//
			// // 将角色资源相关加入到m_resource_scene以及m_roleResList
			// ResHead resHead = new ResHead(
			// ObjectAdapter.RESOURCE_TYPE_ROLE,
			// GameManager.getInstance().m_role.m_name, 1);
			// GameManager.getInstance().m_roleResList.put(resHead);
			// GameManager.getInstance().m_resource_scene.put(resHead,
			// GameManager.getInstance().m_role);
		}
		else {
			setHintMsg("选择人物返回状态 : " + state);
		}
	}
	/**
	 * 读取进入世界
	 * @param dis
	 * @throws IOException
	 */
	private void recvSelectWorldMessage(DataInputStream dis) throws IOException {
		byte state = dis.readByte();// 状态 0失败,1成功
		Tools.debugPrintln("select world : " + state);
		if (state == 1) {
			GameManager.getInstance().m_role = new ActorRole(GameManager.getInstance().m_resource_scene);
			GameManager.getInstance().m_role.m_gameID = dis.readLong();// 角色ID
			Tools.debugPrintln("角色ID : " + GameManager.getInstance().m_role.m_gameID);
			GameManager.getInstance().setGameStatus(GameManager.GS_LOADING);
			Log.d("xltest", "角色ID="+GameManager.getInstance().m_role.m_gameID);
		} else {
			setHintMsg("进入世界失败!");
		}
	}
	// /**
	// * 登入场景
	// * @param type
	// * @param body
	// */
	// private void recvEnterIntoSceneMessage(DataInputStream dis) throws
	// IOException {
	// Tools.debugPrintln("读取切换场景!");
	// GameManager.getInstance().m_role.m_anim =
	// GameManager.getInstance().m_role.m_anims[0];
	// GameManager.getInstance().m_stage = dis.readInt();// 地图ID
	// GameManager.getInstance().m_role.m_posX = dis.readShort();// 坐标 x
	// GameManager.getInstance().m_role.m_posY = dis.readShort();// 坐标 y
	// Tools.debugPrintln("地图ID : " + GameManager.getInstance().m_stage);
	// Tools.debugPrintln("坐标 x : " + GameManager.getInstance().m_role.m_posX);
	// Tools.debugPrintln("坐标 y : " + GameManager.getInstance().m_role.m_posY);
	//
	// GameManager.getInstance().m_role.m_name =
	// m_role_list[m_role_select].m_name;
	// byte dir = dis.readByte();// 人物方向
	// Tools.debugPrintln("人物方向 : " + dir);
	// GameManager.getInstance().m_role.setAction(ActorRole.ACTION_STAND *
	// ActorRole.DIRECT_NUM + dir, true);
	//
	// short resCount = dis.readShort();// 资源个数
	// Tools.debugPrintln("资源个数 : " + resCount);
	// GameManager.getInstance().m_sceneResList.clean();
	// if (resCount > 0) {
	// for (short i = 0; i < resCount; i++) {
	// byte resType = dis.readByte();// 资源类型
	// String resPath = dis.readUTF();// 资源URL
	// int resVersion = dis.readInt();// 资源版本
	// Tools.debugPrintln("资源类型 : " + resType);
	// Tools.debugPrintln("资源URL : " + resPath);
	// Tools.debugPrintln("资源版本 : " + resVersion);
	// ResHead resHead = new ResHead();
	// resHead.m_type = resType;
	// resHead.m_url = resPath;
	// resHead.m_version = resVersion;
	// GameManager.getInstance().m_sceneResList.put(resHead);
	// if (resType == ObjectAdapter.RESOURCE_TYPE_SCENE) {
	// GameManager.getInstance().m_sceneResHead = resHead;
	// }
	// }
	// }
	// GameManager.getInstance().m_sceneResList.merge(GameManager.getInstance().m_roleResList);
	// Tools.debugPrintln("登录场景!");
	// GameManager.getInstance().setGameStatus(GameManager.GS_LOADING);
	// }
//	/**
//	 * 接收世界列表
//	 *
//	 * @param dis
//	 * @throws IOException
//	 */
//	private void recvWorldListMessage(DataInputStream dis) throws IOException
//	{
//		byte amount = dis.readByte();// 世界数量
//		Tools.debugPrintln("世界数量 : " + amount);
//		m_world_list.removeAllElements();
//		for (byte i = 0; i < amount; i++) {
//			Function func = new Function();
//			func.m_id_int = dis.readInt();// 世界ID
//			func.m_name = dis.readUTF();// 世界名字
//			Tools.debugPrintln("第" + i + "个世界ID : " + func.m_id_int);
//			Tools.debugPrintln("第" + i + "个世界名字 : " + func.m_name);
//			m_world_list.addElement(func);
//		}
//		m_role_lock = false;
//	}

	/**
	 * 接收用户中心第一次认证
	 *
	 * @param type
	 * @param body
	 */
	private void recvUserAuthMessage(DataInputStream dis) throws IOException
	{
		byte state = dis.readByte();
		Tools.debugPrintln("state = " + state);
		GameManager.getInstance().m_server_name = dis.readUTF();
		Tools.debugPrintln("服务器名称 : " + GameManager.getInstance().m_server_name);
		m_user_id = dis.readLong();
		GameManager.getInstance().m_permission = dis.readByte();
		if (state != 8) {
			GameManager.getInstance().m_server_id = dis.readInt();
			Tools.debugPrintln("服务器ID : " + GameManager.getInstance().m_server_id);
		}
		if (state == 1) {
			GameManager.s_isControlledByUi = true;
			GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_WRITE);
			final UIMessageBox messageBox = (UIMessageBox) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
			Tools.debugPrintln("messageBox : " + messageBox);
			messageBox.setMessage("账号已经在线,是否将对方踢下线?");
			messageBox.addListener(new UIListener() {
				public void actionPerformed() {
					if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)
							|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
						GameManager.getInstance().m_game_message.sendUserDisconnectAnother();
						GameManager.s_isControlledByUi = false;
						UIManager.getInstance().removeWindow(messageBox);
					}
					else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
						GameManager.s_isControlledByUi = false;
						GameManager.getInstance().closeConnection();
						GameManager.getInstance().clearConnection();
						UIManager.getInstance().removeWindow(messageBox);

						//#if edition == "JIUYOU"|| edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6"
						//# goJiuYou();
						//# setNextState(STATE_LOGIN_SOUND);
						//#endif
					}
				}
			});
			Tools.debugPrintln("开启提示重复登录!");
		} else if (state == 2) {
			if(m_record_auth == GameProtocol.CS_USER_AUTH){
				GameManager.getInstance().m_game_message.sendUserServerList();
			}else{
				m_role_lock = true;
				setNextState(STATE_LOGIN_ROLES);
				GameManager.getInstance().m_game_message.sendUserActorList();
			}
		} else {

			//#if edition == "JIUYOU"|| edition == "JIUYOU_1" || edition == "JIUYOU_2" || edition == "JIUYOU_3" || edition == "JIUYOU_4"|| edition == "JIUYOU_5" || edition == "JIUYOU_6"
			//# GameManager.s_isControlledByUi = true;
			//# final UIMessageBox messageBox = (UIMessageBox) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
			//# Tools.debugPrintln("messageBox : " + messageBox);
			//# if (state >= USERAUTHSTATE.length) {
			//# 	messageBox.setMessage("提示", null, "返回", "登录失败!");
			//# } else {
			//# 	messageBox.setMessage("提示", null, "返回", USERAUTHSTATE[state]);
			//# }
			//# messageBox.addListener(new UIListener() {
			//# 	public void actionPerformed() {
			//# 		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			//# 			GameManager.s_isControlledByUi = false;
			//#				goJiuYou();
			//# 			setNextState(STATE_LOGIN_SOUND);
			//# 			UIManager.getInstance().removeWindow(messageBox);
			//# 		}
			//# 	}
			//# });
			//#endif
		}

		switch (state) {
			case 1:
				setHintMsg("已经登录!");
				break;
			case 2:
				GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_WRITE);
				setHintMsg("登录成功!");
				break;
			case 3:
				setHintMsg("密码错误!");
				break;
			case 4:
				setHintMsg("用户名错误!");
				break;
			case 5:
				setHintMsg("账号锁定!");
				break;
			case 6:
				setHintMsg("账号冻结!");
				break;
			case 7:
				setHintMsg("其他失败!");
				break;
			case 8:
				setHintMsg("请更新客户端!");
				GameMIDlet.s_JumpUrl = dis.readUTF();
				Tools.debugPrintln("GameMIDlet.s_JumpUrl=>>>>>>>>>>>>>"+GameMIDlet.s_JumpUrl);
				exitGame();
				break;
		}
	}

	public String[] USERAUTHSTATE = {"", "已经登录!", "登录成功!", "密码错误!", "用户名错误!", "账号锁定!", "账号冻结!", "其他失败!", "请更新客户端!", "登录无效!"};

	/**
	 * 接收登录返回信息
	 *
	 * @param type
	 * @param body
	 */
	private void recvServerListMessage(DataInputStream dis) throws IOException
	{

		m_server_session = dis.readLong();// 对话标识
		byte serverAmount = dis.readByte();// 服务器数量
		Tools.debugPrintln("对话标识 : " + m_server_session);
		Tools.debugPrintln("服务器数量 : " + serverAmount);
		m_server_list.removeAllElements();
		for (byte i = 0; i < serverAmount; i++) {
			Function func = new Function();
			func.m_name = dis.readUTF();// 服务器名字
			Tools.debugPrintln("服务器名字 : " + func.m_name);
			func.m_ip = dis.readUTF();// 服务器IP
			Tools.debugPrintln("服务器IP : " + func.m_ip);
			func.m_port = dis.readShort();// 服务器port
			Tools.debugPrintln("服务器port : " + func.m_port);
			func.m_role_amount = dis.readByte();// 服务器角色数量
			Tools.debugPrintln("服务器角色数量 : " + func.m_role_amount);
			func.m_status = dis.readByte();//服务器状态 1流畅 2爆满
			Tools.debugPrintln("服务器状态 : " + func.m_status);
			m_server_list.addElement(func);
		}
		setNextState(STATE_LOGIN_SERVER);
		// short state;
		// state = dis.readShort();
		// String str = dis.readUTF();
		//
		// Tools.debugPrintln("state = " + state);
		// Tools.debugPrintln("str = " + str);
		// if (state > 0) {
		// GameManager.getInstance().m_userID = dis.readLong();
		// m_server_count = dis.readByte();
		// Tools.debugPrintln("serverCount = " + m_server_count);
		// if (m_server_count > 0) {
		// m_server_list = new ArrayList();
		// for (byte i = 0; i < m_server_count; i++) {
		// Function func = new Function();
		// readServerList(dis, func);
		// m_server_list.addElement(func);
		// }
		// Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
		// setHintMsg("登录成功,正在进入游戏!");
		// setNextState(STATE_LOGIN_ROLES);
		// }
		// }
	}

	/**
	 * 接收删除人物返回信息
	 *
	 * @param type
	 * @param body
	 */
	private void recvDeleteMessage(DataInputStream dis) throws IOException
	{
		// short state = dis.readShort();
		// dis.readUTF();// 信息
		// Tools.debugPrintln("delete = " + state);
		// if (state == 1) {
		// m_actorList[m_actorSelect] = null;
		// for (int i = 0; i < m_actor_amount; i++) {
		// if (m_actorList[i] == null && (i + 1) < m_actor_amount
		// && m_actorList[i + 1] != null) {
		// m_actorList[i] = m_actorList[i + 1];
		// m_actorList[i + 1] = null;
		// }
		// }
		// m_actor_amount--;
		// }
		byte status = dis.readByte();
		setHintMsg("删除角色状态 : " + status);
		if (status == 1) {
			int day = dis.readInt();
			m_role_list[m_role_select].m_delete = true;
			m_role_list[m_role_select].m_keep_day = day;
			m_role_menu_select = 0;
			m_role_menu = false;
		}
	}

	/**
	 * 接收取消删除人物返回信息
	 *
	 * @param dis
	 * @throws IOException
	 */
	private void recvFindMessage(DataInputStream dis) throws IOException
	{
		byte status = dis.readByte();
		setHintMsg("取消删除角色状态 : " + status);
		if (status == 1) {
			m_role_list[m_role_select].m_delete = false;
			m_role_menu_select = 0;
			m_role_menu = false;
		}
	}

	/**
	 * 接收创建人物返回信息
	 *
	 * @param type
	 * @param body
	 */
	private void recvCreateMessage(DataInputStream dis) throws IOException
	{
		byte status = dis.readByte();
		if (status == 0) {
			setHintMsg("未知错误!");
		}
		else if (status == 1) {
			long id = dis.readLong();// 角色ID
			String url = dis.readUTF();// 资源
			m_role_list[m_role_select] = new ActorRole(m_user_resource);
			m_role_list[m_role_select].m_gameID = id;
			m_role_list[m_role_select].m_name = m_role_name;
			m_role_list[m_role_select].m_sex = (byte) (m_sex_index + 1);
			m_role_list[m_role_select].m_race = (byte) (m_race_index + 1);
			m_role_list[m_role_select].m_vocation = new byte[1];
			m_role_list[m_role_select].m_vocation[0] = (byte) (m_job_index + 1);
			m_role_list[m_role_select].m_lv = 1;
			m_role_list[m_role_select].m_location = "无";
			setNextState(STATE_LOGIN_ROLES);
			Tools.debugPrintln("创建角色URL : " + url);
			url = GameManager.getInstance().getClothHead(m_role_list[m_role_select].m_sex, m_role_list[m_role_select].m_race) + url;
			initRoleRes(m_role_list[m_role_select], url, null);
//			m_role_name = null;
		}
		else if (status == 2) {
			setHintMsg("昵称存在非法字符!");
		}
		else if (status == 3) {
			setHintMsg("昵称重复!");
		}
	}

	private String recvReadHint(DataInputStream dis) throws IOException
	{
//		String text = HyperLink.replaceContent(dis.readUTF());
//		text = HyperLink.replaceMark(text);
		return AbsHyperLinker.removeHyper(dis.readUTF());
	}

	public void recvMessage(int type, byte[] body)
	{
		int order = BaseConnection.s_perseOrderID;
		Tools.debugPrintln("接收到指令号 : " + order);
		GameManager.getInstance().m_game_message.unlockNetwork();
		try {
			ByteArrayInputStream bais = new ByteArrayInputStream(body);
			DataInputStream dis = new DataInputStream(bais);
			switch (order) {
				case GameProtocol.SC_HINT_A:
					Tools.debugPrintln("读取A类提示!");
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_A, recvReadHint(dis));
					break;
				case GameProtocol.SC_HINT_B:
					Tools.debugPrintln("读取B类提示!");
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, recvReadHint(dis));
					break;
				case GameProtocol.SC_HINT_C:
					Tools.debugPrintln("读取C类提示!");
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_C, recvReadHint(dis));
					break;
				case GameProtocol.SC_HINT_D:
					Tools.debugPrintln("读取D类提示!");
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_D, recvReadHint(dis));
					break;
				case GameProtocol.SC_HINT_E:
					Tools.debugPrintln("读取E类提示!");
					GameScene.recvInfo(dis);
					break;
				case GameProtocol.SC_HINT_F:
					Tools.debugPrintln("读取F类提示!");
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_F, recvReadHint(dis));
					break;
				case GameProtocol.SC_USER_AUTH:
				case GameProtocol.CS_USER_REAUTH:
					recvUserAuthMessage(dis);
					break;
				case GameProtocol.SC_USER_SERVER_LIST:
					recvServerListMessage(dis);
					break;
				case GameProtocol.SC_USER_ROLE_LIST:
					recvRoleListMessage(dis);
					break;
				case GameProtocol.SC_USER_CREATE_ROLE:
					recvCreateMessage(dis);
					break;
				case GameProtocol.SC_USER_SELECT_ROLE:
					recvSelectRoleMessage(dis);
					break;
//				case GameProtocol.SC_USER_WORLD_LIST:
//					recvWorldListMessage(dis);
//					break;
				case GameProtocol.SC_USER_DELETE_ROLE:
					recvDeleteMessage(dis);
					break;
				case GameProtocol.SC_USER_FIND_ROLE:
					recvFindMessage(dis);
					break;
				case GameProtocol.SC_USER_REGISTER:
					recvRegister(dis);
					break;
				case GameProtocol.SC_USER_AUTO_REGISTER:
					recvAutoRegister(dis);
					break;
				case GameProtocol.SC_USER_SELECT_WORLD:
					recvSelectWorldMessage(dis);
					break;
				case GameProtocol.SC_USER_CHANGE_PASSWORD:
					recvChangePassword(dis);
					break;
				case GameProtocol.SC_USER_BINDING:
					recvAccountBinding(dis);
					break;
				case GameProtocol.SC_USER_UNBIND:
					recvAccountUnbind(dis);
					break;
				case GameProtocol.SC_USER_RETRIEVE_PASSWORD:
					recvRetrievePassword(dis);
					break;
			}
			dis.close();
			bais.close();
			dis = null;
			bais = null;
		}
		catch (Exception ex) {
			GameManager.getInstance().m_game_message.unlockNetwork();
			Tools.debugPrintln("用户中心网络数据异常！！");
			Tools.debug(ex);
		}
	}

	/**
	 * 接收解除绑定
	 * @param dis
	 * @throws IOException
	 */
	private void recvAccountUnbind(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 0) {
			stringItem.setLabel("提示 :");
			stringItem.setText("未知错误!");
		} else if (status == 1) {
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
			setHintMsg("解绑成功!");
			GameManager.getInstance().closeConnection();
			GameManager.getInstance().clearConnection();
		} else if (status == 2) {
			stringItem.setLabel("提示 :");
			stringItem.setText("账号错误!");
		} else if (status == 3) {
			stringItem.setLabel("提示 :");
			stringItem.setText("密码错误!");
		} else if (status == 4) {
			stringItem.setLabel("提示 :");
			stringItem.setText("已经绑定过!");
		}
	}
	/**
	 * 接收绑定账号
	 * @param dis
	 * @throws IOException
	 */
	private void recvAccountBinding(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 0) {
			stringItem.setLabel("提示 :");
			stringItem.setText("未知错误!");
		} else if (status == 1) {
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
			setHintMsg("绑定成功!");
			GameManager.getInstance().closeConnection();
			GameManager.getInstance().clearConnection();
		} else if (status == 2) {
			stringItem.setLabel("提示 :");
			stringItem.setText("账号错误!");
		} else if (status == 3) {
			stringItem.setLabel("提示 :");
			stringItem.setText("密码错误!");
		} else if (status == 4) {
			stringItem.setLabel("提示 :");
			stringItem.setText("已经绑定过!");
		}
	}

	/**
	 * 接收修改密码
	 * @param dis
	 * @throws IOException
	 */
	private void recvChangePassword(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 0) {
			stringItem.setLabel("提示 :");
			stringItem.setText("未知错误!");
		} else if (status == 1) {
			m_login_password = dis.readUTF();
			GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_WRITE);
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
			setHintMsg("修改密码成功!");
			GameManager.getInstance().closeConnection();
			GameManager.getInstance().clearConnection();
		} else if (status == 2) {
			stringItem.setLabel("提示 :");
			stringItem.setText("账号错误!");
		} else if (status == 3) {
			stringItem.setLabel("提示 :");
			stringItem.setText("密码错误!");
		}
	}

	/**
	 * 接收找回密码
	 * @param dis
	 * @throws IOException
	 */
	private void recvRetrievePassword(DataInputStream dis) throws IOException {
		byte status = dis.readByte();
		if (status == 0) {
			stringItem.setLabel("提示 :");
			stringItem.setText("未知错误!");
		} else if (status == 1) {
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
			GameManager.getInstance().closeConnection();
			GameManager.getInstance().clearConnection();
		} else if (status == 5) {
			stringItem.setLabel("提示 :");
			stringItem.setText("与绑定的手机号码不一致!");
		} else if (status == 6) {
			stringItem.setLabel("提示 :");
			stringItem.setText("与绑定的邮箱不一致!");
		}
	}

	/**
	 * 接收注册信息
	 * @param dis
	 * @throws IOException
	 */
	private void recvRegister(DataInputStream dis) throws IOException
	{
		byte status = dis.readByte();
		if (status == 0) {
			stringItem.setLabel("提示 :");
			stringItem.setText("未知错误!");
		}
		else if (status == 1) {
			m_if_game = true;
//			m_user_state = STATE_LOGIN_MAIN;
			m_trigger = false;
			m_trigger_dir = false;
			m_user_id = dis.readLong();
			GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_WRITE);
			GameManager.s_isControlledByUi = true;
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
			final UIMessageBox mb = (UIMessageBox) UIManager.getInstance().createWindow(
					UIWindowFactory.WINDOW_MESSAGEBOX);
			mb.setMessage("注册成功,是否进入游戏?");
			mb.addListener(new UIListener() {
				public void actionPerformed() {
					if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
							|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
						GameManager.getInstance().m_game_message.sendUserAuth(m_register_name, m_register_password1, GAME_VERSION, m_user_id);
						m_login_name = m_register_name;
						m_login_password = m_register_password1;
						GameManager.s_isControlledByUi = false;
						UIManager.getInstance().removeWindow(mb);
						m_if_game = false;
					}
					else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
						GameManager.s_isControlledByUi = false;
						UIManager.getInstance().removeWindow(mb);
						m_if_game = false;
					}
				}
			});
		}
		else if (status == 2) {
			stringItem.setLabel("提示 :");
			stringItem.setText("账号非法字符!");
		}
		else if (status == 3) {
			stringItem.setLabel("提示 :");
			stringItem.setText("非法账号长度!");
		}
		else if (status == 4) {
			stringItem.setLabel("提示 :");
			stringItem.setText("此账号已存在!");
		}
		else if (status == 5) {
			stringItem.setLabel("提示 :");
			stringItem.setText("密码非法字符!");
		}
		else if (status == 6) {
			stringItem.setLabel("提示 :");
			stringItem.setText("注册账号过多!");
		}
	}

	/**
	 * 接收自动注册
	 * @param dis
	 * @throws IOException
	 */
	public void recvAutoRegister(DataInputStream dis) throws IOException
	{
		byte status = dis.readByte();
		Tools.debugPrintln("自动注册状态 : " + status);
		if (status == 0) {
			setHintMsg("其他错误");
		}
		else if (status == 1) {
			m_register_name = dis.readUTF();
			m_register_password1 = dis.readUTF();
			m_user_id = dis.readLong();
			Tools.debugPrintln("自动注册账号 : " + m_register_name);
			Tools.debugPrintln("自动注册密码 : " + m_register_password1);
			Tools.debugPrintln("自动注册用户ID : " + m_register_name);
			m_if_game = true;
			m_trigger = false;
			m_trigger_dir = false;
			GameManager.s_isControlledByUi = true;
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
			final UIMessageBox mb = (UIMessageBox) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
			mb.setMessage("注册成功" + Tools.CHANGE_ROW
					+ "账号:" + m_register_name + Tools.CHANGE_ROW
					+ "密码:" + m_register_password1 + Tools.CHANGE_ROW
					+ "是否进入游戏?");
			mb.addListener(new UIListener() {
				public void actionPerformed() {
					if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)
							|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT)) {
						GameManager.getInstance().m_game_message.sendUserAuth(m_register_name, m_register_password1, GAME_VERSION, m_user_id);
						m_login_name = m_register_name;
						m_login_password = m_register_password1;
						GameManager.s_isControlledByUi = false;
						UIManager.getInstance().removeWindow(mb);
						m_if_game = false;
						GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_WRITE);
					}
					else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
						GameManager.s_isControlledByUi = false;
						UIManager.getInstance().removeWindow(mb);
						m_if_game = false;
					}
				}
			});
		}
	}

	/**
	 * 读取玩家任务列表
	 *
	 * @param dis
	 * @throws IOException
	 */
	public void recvRoleTaskList(DataInputStream dis) throws IOException
	{
		short state = dis.readShort();
		String msg = dis.readUTF();

		if (state == 1) {
			ActorRole role = GameManager.getInstance().m_role;
			byte dramaCount = dis.readByte();
			Tools.debugPrintln("剧情任务长度 : " + dramaCount);
			for (byte i = 0; i < dramaCount; i++) {
				Task task = new Task();
				task.readTask(dis, UITaskWindow.TASK_TYPE_DRAMA);
				Tools.debugPrintln("创建一个剧情 : " + task.m_name + " : " + task.m_key + " : " + task.m_status);
				role.m_drama_list.addElement(task);
				// task.m_name = dis.readUTF();
				// task.m_id = dis.readInt();
				// task.m_status = dis.readByte();
				// task.m_lv = dis.readInt();
				// task.m_tooltip = dis.readUTF();
				// task.m_progress = dis.readUTF();
				// task.m_difficulty = dis.readByte();
			}
			byte eventCount = dis.readByte();
			Tools.debugPrintln("活动任务长度 : " + eventCount);
			for (byte i = 0; i < eventCount; i++) {
				Task task = new Task();
				task.readTask(dis, UITaskWindow.TASK_TYPE_EVENT);
				Tools.debugPrintln("创建一个活动 : " + task.m_name + " : " + task.m_key + " : " + task.m_status);
				role.m_event_list.addElement(task);
				// task.m_name = dis.readUTF();
				// task.m_id = dis.readInt();
				// task.m_status = dis.readByte();
				// task.m_lv = dis.readInt();
				// task.m_type = task.TASK_TYPE_EVENT;
				// task.m_tooltip = dis.readUTF();
				// task.m_progress = dis.readUTF();
				// task.m_difficulty = dis.readByte();
			}
			// UiManager.s_isControlledByUi = true;
			// UiManager.getInstance().loadWindow(UiManager.WINDOW_TASK_BASE,true);
		}
		else {
			Tools.debugPrintln("读取玩家任务列表失败 : " + msg);
		}
	}

//	private void readTask(DataInputStream dis, Task task) throws IOException
//	{
//		task.m_name = dis.readUTF();
//		task.m_key = dis.readUTF();
//		task.m_status = dis.readByte();
//		task.m_lv = dis.readInt();
//		task.m_type = GameManager.TASK_TYPE_EVENT;
//		task.m_tooltip = dis.readUTF();
//		task.m_progress = dis.readUTF();
//		task.m_difficulty = dis.readByte();
//	}

	/**
	 * 接收处理人物列表返回信息
	 *
	 * @param type
	 * @param body
	 */
	private void recvRoleListMessage(DataInputStream dis) throws IOException
	{
		m_role_amount = dis.readByte();// 角色数量
		m_role_select = 0;
		Tools.debugPrintln("角色数量 = " + m_role_amount);
		if (m_role_list != null) {
			for (int i = 0; i < m_role_list.length; i++) {
				if (m_role_list[i] != null) {
					m_role_list[i].dispose();
					m_role_list[i] = null;
				}
			}
			m_role_list = null;
			m_role_list = new ActorRole[ROLE_LIST_SIZE];
		}
		if (m_role_amount > 3) {
			m_role_amount = 3;
		}
		if (m_role_amount > 0) {
			for (byte i = 0; i < m_role_amount; i++) {
				m_role_list[i] = new ActorRole(m_user_resource);
				readRoleAttribute(dis, m_role_list[i]);
			}
		} else {
			m_sex_index = Tools.getRandom(0, CREATE_SEX_AMOUNT - 1);
			m_race_index = Tools.getRandom(0, CREATE_RECE_AMOUNT - 1);
			m_job_index = Tools.getRandom(0, CREATE_JOB_AMOUNT - 1);
			m_create_select = INDEX_CREATE_NAME;
			m_role_name = "";
			refreshCreateRoleRes();
			setNextState(STATE_LOGIN_CREATE);
		}
		m_angle_create = 0;
		m_role_lock = false;
//		GameManager.getInstance().m_game_message.sendUserWorldList();
	}

	public void initRoleRes(ActorRole role, String url, String wuqi)
	{
		role.m_anims = new Animation[2];
		role.m_refsResHead = new ResHead[2];
		Animation anim;
		if (wuqi != null && !wuqi.equals("")) {
			role.m_refsResHead[1] = new ResHead();
			role.m_refsResHead[1].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;
			role.m_refsResHead[1].m_url = ObjectAdapter.DIR_ANIM.concat(wuqi).concat(ObjectAdapter.EXTENSION_ANIM);
			role.m_refsResHead[1].m_version = 1;
			anim = (Animation) (ResourceManager.getInstance().loadResource(m_user_resource, role.m_refsResHead[1]));
			if( anim != null && anim.m_loadFinished ){
				role.m_anims[1] = anim;
			}else{
				role.m_anims[1] = null;
			}
		}

		role.m_refsResHead[0] = new ResHead();
		role.m_refsResHead[0].m_type = ObjectAdapter.RESOURCE_TYPE_ANIM;
		role.m_refsResHead[0].m_url = ObjectAdapter.DIR_ANIM.concat(url).concat(ObjectAdapter.EXTENSION_ANIM);
		role.m_refsResHead[0].m_version = 1;
		anim = (Animation) (ResourceManager.getInstance().loadResource(m_user_resource, role.m_refsResHead[0]));
		if(anim != null && anim.m_loadFinished ){
			role.m_anims[0] = anim;
		}else{
			String shadow_url = ObjectAdapter.DIR_ANIM.concat("heim_dk_r_1").concat(
					ObjectAdapter.EXTENSION_ANIM);// 读取角色动画资源URL
			ResHead resHead = new ResHead(ObjectAdapter.RESOURCE_TYPE_ANIM, shadow_url, ResHead.BASE_VERSION);
			Animation anim_old = (Animation) (ResourceManager.getInstance().loadResource(m_user_resource, resHead));
			if( anim_old != null && anim_old.m_loadFinished){
				role.m_anims[0] = anim_old;
			}else{
				Tools.debugPrintln("创建时装影子也为空");
				role.m_anims[0] = null;
			}
		}
		role.m_anim = role.m_anims[0];
		role.setActionFrame(2, 0);
	}

	/**
	 * 读取一个玩家属性
	 * @param dis
	 * @param vec
	 */
	private void readRoleAttribute(DataInputStream dis, ActorRole role)
	{
		try {
			Tools.debugPrintln("读取一个角色!");
			role.m_gameID = dis.readLong();// ID
			Tools.debugPrintln("ID : " + role.m_gameID);
			role.m_name = dis.readUTF();// 名称
			Tools.debugPrintln("名称 : " + role.m_name);
			role.m_lv = dis.readInt();// 等级
			Tools.debugPrintln("等级 : " + role.m_lv);
			role.m_sex = dis.readByte();// 性别
			Tools.debugPrintln("性别 : " + role.m_sex);
			role.m_race = dis.readByte();// 种族
			Tools.debugPrintln("种族 : " + role.m_race);
			short size = dis.readShort();
			Tools.debugPrintln("职业转数 : " + size);
			role.m_vocation = new byte[size];
			for (short i = 0; i < size; i++) {
				role.m_vocation[i] = dis.readByte();// 职业
			}
			Tools.debugPrintln("职业 : " + role.m_vocation[role.m_vocation.length - 1]);
			String url = dis.readUTF();// 资源地址
			Tools.debugPrintln("资源地址 : " + url);
			String wuqi = dis.readUTF();
			Tools.debugPrintln("装备资源地址 : " + wuqi);
			role.m_location = dis.readUTF();// 最后下线场景
			Tools.debugPrintln("下线场景 : " + role.m_location);
			role.m_delete = dis.readByte() == 0 ? false : true;
			Tools.debugPrintln("是否被删除 : " + role.m_delete);
			if (role.m_delete) {
				role.m_keep_day = dis.readInt();
				Tools.debugPrintln("保留剩余天数 : " + role.m_keep_day);
			}
			url = GameManager.getInstance().getClothHead(role.m_sex, role.m_race) + url;
			initRoleRes(role, url, wuqi);
		}
		catch (IOException ex) {
			Tools.debug(ex);
		}
	}
	/**
	 * 绘制一个带美术字的框
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 * @param index
	 */
	public final void drawRectByWord(Graphics g, int x, int y, int w, int h, int index, boolean select) {
		UITools.paintLabel(g, x, y, w, h, select);
		if (!select) {
			int num = m_timer % 5;
			if (num >= 3) {
				num = 5 - num;
			}
			g.drawImage(img_select, x - num + 6, y + (h >> 1) + 1, Tools.RIGHT_VCENTER);
			Tools.drawRegion(g, img_select, x + w + num - 5, y + (h >> 1) + 1, Tools.TRANS_H, Tools.LEFT_VCENTER);
		}
		if (img_word_list != null && index < img_word_list.length && img_word_list[index] != null) {
			g.drawImage(img_word_list[index], x + (w >> 1), y + (h >> 1), Tools.HCENTER_VCENTER);
		}
	}

	public static void drawColorString(Graphics g, String text, int x, int y,
			int color,int dot)
	{
		g.setColor(color);
		g.drawString(text, x, y, dot);
	}

	public void setHintMsg(String msg)
	{
		m_hintMsg = msg;
		m_hintTimer = HINT_TIME;
	}

	public void setNextState(int nextState)
	{
		m_next_user_state = nextState;
		Tools.debugPrintln("setNextState : " + nextState);
		GameTouchManager.clearStaticRects();
		if (nextState == STATE_LOGIN_MAIN) {
//			m_angle = 0;
			m_trigger = false;
			m_trigger_dir = false;
//			if (GameManager.canLoadUserRMSData(GameManager.RMS_INDEX_USER)) {
//				Tools.debugPrintln("无数据,初始化rms");
//			}
//			GameManager.initUserRMSData();
//			GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_READ);
		}
		if( nextState == STATE_LOGIN_SERVER ){
			m_in_select = true;
		}
	}

	public static final int WIDTH_LOGIN_NAME = (AbstractGameScreen.SCREEN_WIDTH >> 2) * 3;
	public static final int HEIGHT_LOGIN_NAME = 20;
	public static final int POINTER_X_LOGIN_NAME = (AbstractGameScreen.SCREEN_WIDTH - WIDTH_LOGIN_NAME + 30) >> 1;
	public static final int POINTER_Y_LOGIN_NAME = AbstractGameScreen.SCREEN_HEIGHT >> 2;

	public static final int WIDTH_LOGIN_PASSWORD = (AbstractGameScreen.SCREEN_WIDTH >> 2) * 3;
	public static final int HEIGHT_LOGIN_PASSWORD = 20;
	public static final int POINTER_X_LOGIN_PASSWORD = POINTER_X_LOGIN_NAME;
	public static final int POINTER_Y_LOGIN_PASSWORD = POINTER_Y_LOGIN_NAME + HEIGHT_LOGIN_NAME + 10;

	// public static final int POINTER_X_SELECT_SERVER = 20;
	// public static final int POINTER_Y_SELECT_SERVER = 80;
	// public static final int GAP_Y_SELECT_SERVER = 30;

	// public static final int POINTER_X_SELECT_ACTOR = 20;
	// public static final int POINTER_Y_SELECT_ACTOR = 80;
	// public static final int GAP_Y_SELECT_ACTOR = 30;

	public static final String WORD_LOGIN_NAME = "账号";
	public static final String WORD_LOGIN_PASSWORD = "密码";

	// public String m_loginAgainPassword = null;

	// private final String[] LOGIN_MENU_LIST = {"快速注册", "登录游戏", "帮助关于",
	// "账号充值", "修复游戏", "游戏设置", "退出"};
	// private final int HEIGHT_MENU_INTERSPACE = 5;
	// private final int HEIGHT_MENU_LIST = LOGIN_MENU_LIST.length
	// * (AbstractGameScreen.FONT_H + HEIGHT_MENU_INTERSPACE);
	// private final int COORD_X_MENU_LIST = AbstractGameScreen.SCREEN_WIDTH >>
	// 1;
	// private final int COORD_Y_MENU_LIST = AbstractGameScreen.SCREEN_HEIGHT
	// - HEIGHT_MENU_LIST >> 1;
	/** 登录界面索引 - 快速注册 */
	public static final int INDEX_LOGIN_KSZC = 0;
	/** 登录界面索引 - 账号注册 */
	public static final int INDEX_LOGIN_ZHZC = 1;
	/** 登录界面索引 - 登录游戏 */
	public static final int INDEX_LOGIN_DLYX = 2;
//	/** 登录界面索引 - 账号充值 */
//	public static final int INDEX_LOGIN_ZHCZ = 3;
//	/** 登录界面索引 - 修复游戏 */
//	public static final int INDEX_LOGIN_XFYX = 4;
//	/** 登录界面索引 - 游戏设置 */
//	public static final int INDEX_LOGIN_YXSZ = 5;
//	/** 登录界面索引 - 退出游戏 */
//	public static final int INDEX_LOGIN_TCYX = 6;
	/** 登录界面索引 - 索引总数 */
	public static final int INDEX_LOGIN_COUNT = INDEX_LOGIN_DLYX + 1;
	/** 登录界面选择下标 */
	private int m_main_select = INDEX_LOGIN_KSZC;

	/** 创建人物界面索引 - 昵称 */
	public static final int INDEX_CREATE_NAME = 3;
	/** 创建人物界面索引 - 性别 */
	public static final int INDEX_CREATE_SEX = 2;
	/** 创建人物界面索引 - 职业 */
	public static final int INDEX_CREATE_JOB = 0;
	/** 创建任务界面索引 - 阵营 */
	public static final int INDEX_CREATE_RACE = 1;
	/** 创建任务界面索引 - 创建 */
	public static final int INDEX_CREATE_CREATE = 4;
	/** 创建任务界面索引 - 信息 */
	public static final int INDEX_CREATE_MSG = 5;
	/** 创建人物界面索引 - 索引总数 */
	public static final int INDEX_CREATE_COUNT = 6;


	// /** 人物界面选择人物下标 */
	// private int m_actorSelect = 0;

	/** 登录状态 - 登录界面,服务器界面,人物界面 */
	public int m_user_state = -1;
	/** 下一个登录状态 */
	private int m_next_user_state = -1;
	/** 用户中心状态 - logo */
	public static final byte STATE_LOGO = 0;
	/** 用户中心状态 - 加载中 */
	public static final byte STATE_LOADING = 1;
	/** 用户中心状态 - 主界面 */
	public static final byte STATE_LOGIN_MAIN = 2;
	/** 用户中心状态 - 注册账号 */
	private final byte STATE_LOGIN_REG = 3;
	/** 用户中心状态 - 登录游戏 */
	private final byte STATE_LOGIN_LOGIN = 4;
	/** 用户中心状态 - 帮助关于 */
	private final byte STATE_LOGIN_HELP = 5;
	/** 用户中心状态 - 账号充值 */
	private final byte STATE_LOGIN_TOPUP = 6;
	/** 用户中心状态 - 修复游戏 */
	private final byte STATE_LOGIN_REPAIT = 7;
	/** 用户中心状态 - 游戏设置 */
	private final byte STATE_LOGIN_SET = 8;
	/** 用户中心状态 - 人物界面 */
	private final byte STATE_LOGIN_ROLES = 9;
	/** 用户中心状态 - 服务器界面 */
	private final byte STATE_LOGIN_SERVER = 10;
	/** 用户中心状态 - 创建人物界面 */
	private final byte STATE_LOGIN_CREATE = 11;
	/** 用户中心状态 - 返回选择人物 */
	public static final byte STATE_LOGIN_BACK = 12;
	/** 用户中心状态 - 资源异常界面 */
	public static final byte STATE_LOGIN_EXCEPTION = 13;
	/** 用户中心状态 - 声音界面 */
	public static final byte STATE_LOGIN_SOUND = 14;
	/** 用户中心状态 - 第一次注册 */
	public static final byte STATE_LOGIN_NEW_REG = 15;
	/** 用户中心状态 - 第一次登录 */
	public static final byte STATE_LOGIN_NEW_LOGIN = 16;
	// /** 用户中心状态 - loading */
	// private final byte STATE_LOGIN_LOADING = 10;

	/** 转换提示时间 */
	private int m_hintTimer = 0;
	/** 转换提示默认总时间 */
	public final int HINT_TIME = 20;
	/** 提示信息 */
	private String m_hintMsg = null;
	// //////////////////////////////////////////////////////////////
	// logo
	// //////////////////////////////////////////////////////////////

	private byte m_logo_index = 0;
	private byte m_logo_time = 0;


	private Image[] img_logo = null;

	// //////////////////////////////////////////////////////////////
	// 用户中心通用
	// //////////////////////////////////////////////////////////////
	private ArrayList m_star_list = new ArrayList();
	private Image img_small_star = null;
	private Image img_big_star = null;

//	private final byte IMG_INDEX_BG = 0;// 背景
//	private final byte IMG_INDEX_CORNER1 = 1;// 小角
//	private final byte IMG_INDEX_CORNER2 = 2;// 中角
//	private final byte IMG_INDEX_CORNER3 = 2;// 大角
//	private final byte IMG_INDEX_ARROWS1 = 4;// 小箭头
//	private final byte IMG_INDEX_ARROWS2 = 5;// 大箭头
//	private final byte IMG_INDEX_CHOOSE_BG = 3;// 选择框背景
//	private final byte IMG_INDEX_CHOOSE_CN = 4;// 对号
//	private final byte IMG_INDEX_AN_CORNER = 5;// 按钮角
//	private final byte IMG_INDEX_AN_BAR1 = 6;// 暗条
//	private final byte IMG_INDEX_AN_BAR2 = 7;// 亮条
//	private final byte IMG_INDEX_SCENE1 = 11;// 场景1
//	private final byte IMG_INDEX_SCENE2 = 12;// 场景2
//	private final byte IMG_INDEX_ABG1 = 8;// 透明背景
//	private final byte IMG_INDEX_BG2 = 9;// 创建人物界面等背景
//	private final byte IMG_INDEX_OK = 10;// 确定
//	private final byte IMG_INDEX_RETURN = 11;// 返回
//	private final byte IMG_INDEX_LG = 12;// 亮光
//	private final byte IMG_INDEX_LH = 13;// 莲花

	private Image img_bar_big = null;
	private Image img_bar_small = null;

//	private Image[] img_user = null;
//	private String[] IMG_NAME = { "beijing.png", "4.png",
//			"decorate_big.png",
//			"choose_background.png", "choose.png", "anniu_bian.png",
//			"anniu_tiao.png", "anniu_liangtiao.png",
//			"touming_beijing.png", "beijing2.png",
//			"quedinganniu.png", "fanhuianniu.png", "liangguang.png",
//			"lianhua_houmian.png" };
//	private Image[] img_word = null;
//	private String[] IMG_WORD = { "kuaisuzhuce.png", "dengluyouxi.png",
//			"bangzhuguanyu.png", "zhanghaochongzhi.png", "xiufuyouxi.png",
//			"youxishezhi.png", "tuichu.png", "kuaisuzhuce1.png",
//			"dengluyouxi1.png", "bangzhuguanyu1.png", "zhanghaochongzhi1.png",
//			"xiufuyouxi1.png", "youxishezhi1.png", "tuichu1.png" };

	private Image img_lianhua = null;
	private Image img_select = null;
	private Image img_choose_bg = null;
	private Image img_choose_cn = null;
	private Image img_background = null;
	private Image img_background_logo = null;
	private Image[] img_word_list = null;
	private final String WORD_PATH = "/login/temp/w_";
	private final String WORD_POSTFIX = ".png";
	private final String[] WORD_LIST = {
			"qd",
			"tc",
			"kq",
			"gb",
			"xb",
			"zy",
			"zz",
			"nc",
			"zh",
			"mm",
//			"cfmm",
			"ksjr",
			"zhzc",
			"dlyx",
			"yxsz",
			"zhgl",
			"yxbz",
//			"xgmm",
//			"zhbd",
//			"zhzh",
//			"jcbd",
			"cjjm",
			"rwjm",
			"cjjs",
			"jzzhjmm",
			"dl",
			"jryx",
			"scjs",
			"fh",
			"hyjs",
			"dqrwlb",
			"fwqlb",
	};

	private final byte WORD_INDEX_QD = 0;
	private final byte WORD_INDEX_TC = 1;
	private final byte WORD_INDEX_KQ = 2;
	private final byte WORD_INDEX_GB = 3;
	private final byte WORD_INDEX_XB = 4;
	private final byte WORD_INDEX_ZY = 5;
	private final byte WORD_INDEX_ZZ = 6;
	private final byte WORD_INDEX_NC = 7;
	private final byte WORD_INDEX_ZH = 8;
	private final byte WORD_INDEX_MM = 9;
//	private final byte WORD_INDEX_CFMM = 10;
	private final byte WORD_INDEX_KSJR = 10;
	private final byte WORD_INDEX_ZHZC = 11;
	private final byte WORD_INDEX_DLYX = 12;
	private final byte WORD_INDEX_YXSZ = 13;
	private final byte WORD_INDEX_ZHGL = 14;
	private final byte WORD_INDEX_YXBZ = 15;
//	private final byte WORD_INDEX_XGMM = 17;
//	private final byte WORD_INDEX_ZHBD = 18;
//	private final byte WORD_INDEX_ZHZH = 19;
//	private final byte WORD_INDEX_JCBD = 20;
	private final byte WORD_INDEX_CJJM = 16;
	private final byte WORD_INDEX_RWJM = 17;
	private final byte WORD_INDEX_CJJS = 18;
	private final byte WORD_INDEX_JZZHJMM = 19;
	private final byte WORD_INDEX_DL = 20;
	private final byte WORD_INDEX_JRYX = 21;
	private final byte WORD_INDEX_SCJS = 22;
	private final byte WORD_INDEX_FH = 23;
	private final byte WORD_INDEX_HYJS = 24;
	private final byte WORD_INDEX_DQRWLB = 25;
	private final byte WORD_INDEX_FWQLB = 26;

	// //////////////////////////////////////////////////////////////
	// 创建人物界面
	// //////////////////////////////////////////////////////////////
//	private int X_CREATE_BG = 0;// 人物背景
//	private int Y_CREATE_BG = 0;
//	private int W_CREATE_BG = 0;
//	private int H_CREATE_BG = 0;
	private int X_CREATE_SEX = 0;// 性别
	private int Y_CREATE_SEX = 0;
	private int X_CREATE_JOB = 0;// 职业
	private int Y_CREATE_JOB = 0;
	private int X_CREATE_RACE = 0;// 种族
	private int Y_CREATE_RACE = 0;
	private int X_CREATE_NAME = 0;// 名字
	private int Y_CREATE_NAME = 0;
	private int W_CREATE_NAME = 0;
//	private int H_CREATE_NAME = 0;
	private int X_CREATE_MSG = 0;// 信息
	private int Y_CREATE_MSG = 0;
	private int W_CREATE_MSG = 0;
	private int H_CREATE_MSG = 0;

	private int W_BOX_SEX = 20;
	private int H_BOX_SEX = 20;

	private Image img_sex = null;
	private Image img_job = null;
	private Image img_race = null;
//	private Image img_job_name = null;
//	private Image img_race_name = null;
	private Image img_cursor_corner = null;
	private Image img_cursor_side = null;
	private Image img_delete_role = null;

	private int m_create_select = 0;// 创建角色选择下标
	private String m_role_name = "";// 创建角色的昵称
	private Form form = new Form("登录");
	public StringItem stringItem = new StringItem("", "", StringItem.PLAIN);
	public StringItem register_hint = new StringItem("", "", StringItem.PLAIN);

	private TextField register_name = new TextField("", "", 20, TextField.ANY);
	private TextField register_phone = new TextField("", "", 20, TextField.PHONENUMBER);
	private TextField register_password1 = new TextField("", "", 20, TextField.PASSWORD);
	private TextField register_password2 = new TextField("", "", 20, TextField.PASSWORD);
	private TextField register_password3 = new TextField("", "", 20, TextField.PASSWORD);

	private TextField register_email = new TextField("", "", 50, TextField.EMAILADDR);

	private String m_register_name = null;//注册名字
	private String m_register_password1 = null;//注册密码1
	private String m_register_password2 = null;//注册密码2

	private boolean m_if_game = false;//询问是否进入游戏,成功注册后

	private byte m_account_manage_select = 0;//账号管理索引

	private final byte ACCOUNT_MANAGE_PASSWORD = 0;//账号管理 - 修改密码
	private final byte ACCOUNT_MANAGE_BINDING = 1;//账号绑定
	private final byte ACCOUNT_MANAGE_BACK = 2;//找回账号
	private final byte ACCOUNT_MANAGE_UNBIND = 3;//解除绑定

	private Command ok = new Command("确定", Command.OK, 1);
	private Command back = new Command("返回", Command.BACK, 1);
    //重要
	private final byte ACCOUNT_MIN_SIZE = 6;//账号最小长度
	private final byte ACCOUNT_MAX_SIZE = 11;//账号最大长度

	private final byte PASSWORD_MIN_SIZE = 6;//密码最小长度
	private final byte PASSWORD_MAX_SIZE = 11;//密码最大长度

	public void commandAction(Command key, Displayable arg1)
	{
		if (key == back) {
			Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
		}
		else if (key == ok) {
			Tools.debugPrintln("user state = " + m_user_state + " : " + m_login_select + " : " + m_account_manage_select);
			switch (m_user_state) {
				case STATE_LOGIN_LOGIN:
					switch (m_login_select) {
						case LOGIN_INDEX_ZH:// 用户名
						case LOGIN_INDEX_MM:// 密码
							String resultAccount = checkAccount(register_name.getString());
							String resultPassword = checkPassword(register_password1.getString());
							if (resultAccount != null) {
								stringItem.setLabel("提示 :");
								stringItem.setText(resultAccount);
							} else if (resultPassword != null) {
								stringItem.setLabel("提示 :");
								stringItem.setText(resultPassword);
							} else {
								m_login_name = register_name.getString();
								m_login_password = register_password1.getString();
								Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
							}
							break;
						case LOGIN_INDEX_ZHGL:
							switch (m_account_manage_select) {
								case ACCOUNT_MANAGE_PASSWORD:
									String new1 = register_password2.getString();
									String new2 = register_password3.getString();
									String old = register_password1.getString();
									resultAccount = checkAccount(register_name.getString());
									resultPassword = checkPassword(register_password1.getString());
									String reultNew1 = checkPassword(new1);
									String reultNew2 = checkPassword(new2);
									if (resultAccount != null) {
										stringItem.setLabel("提示 :");
										stringItem.setText(resultAccount);
									} else if (resultPassword != null) {
										stringItem.setLabel("提示 :");
										stringItem.setText(resultPassword);
									} else if (reultNew1 != null) {
										stringItem.setLabel("提示 :");
										stringItem.setText(reultNew1);
									} else if (reultNew2 != null) {
										stringItem.setLabel("提示 :");
										stringItem.setText(reultNew2);
									} else if (!new1.equals(new2)) {
										stringItem.setLabel("提示 :");
										stringItem.setText("两次新密码不符!");
									} else if (old.equals(new1)) {

										stringItem.setLabel("提示 :");
										stringItem.setText("旧密码与新密码相同!");
									} else {
										if (GameManager.getInstance().getConnection() == null) {
											try {
												GameManager.getInstance().m_game_message.unlockNetwork();
												GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
												GameManager.getInstance().getConnection().open();
											} catch (Exception ex) {
												Tools.debug(ex);
											}
										}
										stringItem.setLabel("提示 :");
										stringItem.setText("服务请求中...");
										GameManager.getInstance().m_game_message.sendUserChangePassword(register_name.getString(), m_user_id, old, new1);
									}
									break;
								case ACCOUNT_MANAGE_BINDING:
									resultAccount = checkAccount(register_name.getString());
									resultPassword = checkPassword(register_password1.getString());
									String phone = register_phone.getString();
									String email = register_email.getString();
									if (resultAccount != null) {
										stringItem.setLabel("提示 :");
										stringItem.setText(resultAccount);
									} else if (resultPassword != null) {
										stringItem.setLabel("提示 :");
										stringItem.setText(resultPassword);
									}
									if( (phone == null || phone.equals("")) && (email == null || email.equals(""))){
										stringItem.setLabel("提示 :");
										stringItem.setText("手机号与邮箱需要填写一项!");
									}
									else if ( phone == null || phone.length() != 11) {
										if (email != null && !email.equals("")) {
											if (GameManager.getInstance().getConnection() == null) {
												try {
													GameManager.getInstance().m_game_message.unlockNetwork();
													GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
													GameManager.getInstance().getConnection().open();
												} catch (Exception ex) {
													Tools.debug(ex);
												}
											}
											stringItem.setLabel("提示 :");
											stringItem.setText("服务请求中...");
											GameManager.getInstance().m_game_message.sendUserBinding(
													register_name.getString(), register_password1.getString(), "", email);
										} else {
											stringItem.setLabel("提示 :");
											stringItem.setText("手机号码格式不正确!");
										}
									} else if (email == null || email.equals("")) {
										if (phone.length() == 11) {
											if (GameManager.getInstance().getConnection() == null) {
												try {
													GameManager.getInstance().m_game_message.unlockNetwork();
													GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
													GameManager.getInstance().getConnection().open();
												} catch (Exception ex) {
													Tools.debug(ex);
												}
											}
											stringItem.setLabel("提示 :");
											stringItem.setText("服务请求中...");
											GameManager.getInstance().m_game_message.sendUserBinding(
													register_name.getString(), register_password1.getString(), phone, "");
										} else {
											stringItem.setLabel("提示 :");
											stringItem.setText("邮箱不能为空!");
										}
									} else {
										if (GameManager.getInstance().getConnection() == null) {
											try {
												GameManager.getInstance().m_game_message.unlockNetwork();
												GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
												GameManager.getInstance().getConnection().open();
											} catch (Exception ex) {
												Tools.debug(ex);
											}
										}
										stringItem.setLabel("提示 :");
										stringItem.setText("服务请求中...");
										GameManager.getInstance().m_game_message.sendUserBinding(
												register_name.getString(), register_password1.getString(), phone, "");

									}
									break;
								case ACCOUNT_MANAGE_UNBIND:
									resultAccount = checkAccount(register_name.getString());
									resultPassword = checkPassword(register_password1.getString());
									if (resultAccount != null) {
										stringItem.setLabel("提示 :");
										stringItem.setText(resultAccount);
									} else if (resultPassword != null) {
										stringItem.setLabel("提示 :");
										stringItem.setText(resultPassword);
									} else {
										if (GameManager.getInstance().getConnection() == null) {
											try {
												GameManager.getInstance().m_game_message.unlockNetwork();
												GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
												GameManager.getInstance().getConnection().open();
											} catch (Exception ex) {
												Tools.debug(ex);
											}
										}
										stringItem.setLabel("提示 :");
										stringItem.setText("服务请求中...");
										GameManager.getInstance().m_game_message.sendUserUnbind(register_name.getString(), register_password1.getString());
									}
									break;
								case ACCOUNT_MANAGE_BACK:
									phone = register_phone.getString();
									email = register_email.getString();
									if (phone == null || phone.equals("")) {//手机号为空
										if (email != null && !email.equals("")) {
											if (GameManager.getInstance().getConnection() == null) {
												try {
													GameManager.getInstance().m_game_message.unlockNetwork();
													GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
													GameManager.getInstance().getConnection().open();
												} catch (Exception ex) {
													Tools.debug(ex);
												}
											}
											stringItem.setLabel("提示 :");
											stringItem.setText("服务请求中...");
											GameManager.getInstance().m_game_message.sendUserRetrievePassword(phone, email);
										} else {
											stringItem.setLabel("提示 :");
											stringItem.setText("手机号与邮箱需要填写一项!");
										}
									} else if (email == null || email.equals("")) {//邮箱为空
										if (phone != null && !phone.equals("")) {
											if (phone.length() != 11) {
												stringItem.setLabel("提示 :");
												stringItem.setText("手机号长度不正确!");
											} else {
												if (GameManager.getInstance().getConnection() == null) {
													try {
														GameManager.getInstance().m_game_message.unlockNetwork();
														GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
														GameManager.getInstance().getConnection().open();
													} catch (Exception ex) {
														Tools.debug(ex);
													}
												}
												stringItem.setLabel("提示 :");
												stringItem.setText("服务请求中...");
												GameManager.getInstance().m_game_message.sendUserRetrievePassword(phone, email);
											}
										} else {
											stringItem.setLabel("提示 :");
											stringItem.setText("手机号与邮箱需要填写一项!");
										}
									}
									break;
							}
							break;
						case LOGIN_INDEX_ZHZC://注册
							m_register_name = register_name.getString();
							m_register_password1 = register_password1.getString();
							m_register_password2 = register_password2.getString();
							resultAccount = checkAccount(m_register_name);
							resultPassword = checkPassword(m_register_password1);
							if (resultAccount != null) {
								stringItem.setLabel("提示 :");
								stringItem.setText(resultAccount);
							}
							else if (resultPassword != null) {
								stringItem.setLabel("提示 :");
								stringItem.setText(resultPassword);
							}
							else if (!m_register_password2.equals(m_register_password1)) {
								stringItem.setLabel("提示 :");
								stringItem.setText("二次密码与密码不符!");
							}
							else {
								if (GameManager.getInstance().getConnection() == null) {
									try {
										GameManager.getInstance().m_game_message.unlockNetwork();
										GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
										GameManager.getInstance().getConnection().open();
									}
									catch (Exception ex) {
										Tools.debug(ex);
									}
								}
								stringItem.setLabel("");
								stringItem.setText("");
								GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_READ);
								String tt;
								if ( m_httpsuccess == 0) {//0超时
									tt = "" + 3;
								}
								else if ( m_httpsuccess == 2) {//2失败
									tt = "" + 2;
								}
								else {
									tt = HttpConnect.NUMBER;
								}
								GameManager.getInstance().m_game_message.sendUserRegister(m_user_id, m_register_name,
										m_register_password1, HttpConnect.IMEI, HttpConnect.USERAGNET, tt);
							}
							break;
					}
					break;
				case STATE_LOGIN_NEW_LOGIN:
					switch (m_login_select) {
						case 0:// 用户名
						case 1:// 密码
							String resultAccount = checkAccount(register_name.getString());
							String resultPassword = checkPassword(register_password1.getString());
							if (resultAccount != null) {
								stringItem.setLabel("提示 :");
								stringItem.setText(resultAccount);
							}
							else if (resultPassword != null) {
								stringItem.setLabel("提示 :");
								stringItem.setText(resultPassword);
							}
							else {
								m_login_name = register_name.getString();
								m_login_password = register_password1.getString();
								Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
							}
							break;
					}
					break;
				case STATE_LOGIN_CREATE:
					String nick = register_name.getString();
					if (nick == null || nick.equals("")) {
						stringItem.setLabel("提示 :");
						stringItem.setText("昵称不能为空!");
					}
					else if (nick.length() > 6) {
						stringItem.setLabel("提示 :");
						stringItem.setText("昵称不得高于6位!");
					}//重要
					else if (nick.length() < 2) {
						stringItem.setLabel("提示 :");
						stringItem.setText("昵称不得少于两位!");
					}
					else {
						m_role_name = register_name.getString();
						if (m_create_msg != null) {
							m_create_msg[0] = "名字 : " + m_role_name;
						}
						Display.getDisplay(GameMIDlet.s_instance).setCurrent(GameMIDlet.s_canvas);
					}
					break;
				case STATE_LOGIN_MAIN:
					m_register_name = register_name.getString();
					m_register_password1 = register_password1.getString();
					m_register_password2 = register_password2.getString();
					String resultAccount = checkAccount(register_name.getString());
					String resultPassword = checkPassword(register_password1.getString());
					if (resultAccount != null) {
						stringItem.setLabel("提示 :");
						stringItem.setText(resultAccount);
					} else if (resultPassword != null) {
						stringItem.setLabel("提示 :");
						stringItem.setText(resultPassword);
					} else if (!m_register_password2.equals(m_register_password1)) {
						stringItem.setLabel("提示 :");
						stringItem.setText("二次密码与密码不符!");
					} else {
						if (GameManager.getInstance().getConnection() == null) {
							try {
								GameManager.getInstance().m_game_message.unlockNetwork();
								GameManager.getInstance().createConnection(GameManager.SERVER_URL, GameManager.SERVER_PORT);
								GameManager.getInstance().getConnection().open();
							} catch (Exception ex) {
								Tools.debug(ex);
							}
						}
						stringItem.setLabel("");
						stringItem.setText("");
						GameManager.manageUserRMSData(GameManager.RMS_INDEX_USER, GameManager.R_READ);
						String temp;
						if ( m_httpsuccess== 0) {//0超时
							temp = "" + 3;
						}
						else if ( m_httpsuccess == 2) {//2失败
							temp = "" + 2;
						}
						else {
							temp = HttpConnect.NUMBER;
						}
						GameManager.getInstance().m_game_message.sendUserRegister(m_user_id, m_register_name,
								m_register_password1, HttpConnect.IMEI, HttpConnect.USERAGNET, temp);
					}
					break;
			}
		}
	}

	private String checkAccount(String account) {
		if (account == null || account.equals("")) {
			return "账号不能为空!";
		} else if (account.length() < ACCOUNT_MIN_SIZE) {
			return "账号不能少于" + ACCOUNT_MIN_SIZE + "个字符!";
		} else if (account.length() > ACCOUNT_MAX_SIZE) {
			return "账号不能超过" + ACCOUNT_MAX_SIZE + "个字符!";
		} else if (isIncludeChinese(account)) {
			return "账号不能为中文";
		}
		return null;
	}

	private String checkPassword(String password) {
		if (password == null || password.equals("")) {
			return "密码不能为空!";
		} else if (password.length() < PASSWORD_MIN_SIZE) {
			return "密码不得少于" + PASSWORD_MIN_SIZE + "位!";
		} else if (password.length() > PASSWORD_MAX_SIZE) {
			return "密码不得高于" + PASSWORD_MAX_SIZE + "位!";
		} else if (isIncludeChinese(password)) {
			return "密码不能为中文!";
		}
		return null;
	}
	/**
	 * 检查字符串中是否有中文
	 * @param text
	 * @return
	 */
	private boolean isIncludeChinese(String text)
	{
		byte[] bytes = text.getBytes();
		for (int i = 0; i < bytes.length; i++) {
			if (bytes[i] == 63) {
				return true;
			}
		}
		return false;
	}

	// //////////////////////////////////////////////////////////////
	// 人物列表界面
	// //////////////////////////////////////////////////////////////
	private Animation m_anim_flower = null;
	private Actor m_actor_flower = null;
	private int m_flower_w = 76;
	private boolean m_role_lock = false;// 是否锁定人物界面
	private boolean m_role_menu = false;// 是否弹出二级菜单
	public byte m_role_select = 0;// 人物选择下标
	private byte m_role_menu_select = 0;// 二级菜单下标

	private final byte ROLE_LIST_SIZE = 3;// 人物列表数量限制

	public ActorRole[] m_role_list = new ActorRole[ROLE_LIST_SIZE];// 人物列表
	public ActorRole m_create_role = null;
	public Resource m_user_resource = null;
	public byte m_role_amount = 0;// 角色数量

//	private ArrayList m_world_list = new ArrayList();// 世界列表
//	private boolean m_role_world = false;// 是否打开世界列表
//	private byte m_role_world_select = 0;// 世界列表下标
	// //////////////////////////////////////////////////////////////
	// 登录游戏界面
	// //////////////////////////////////////////////////////////////
	public static boolean m_save_name = true;// 是否保存用户名和密码
	public static String m_login_name = "";
	public static String m_login_password = "";
	public static long m_user_id = -1;//用户ID

	private byte m_login_select = 0;// 登录游戏选择下标
//	private final int X_NAME = 60;
//	private final int Y_NAME = 40;
//	private final int Y_PASSWORD = 75;
	private final int WIDTH_SCREEN_2_1 = AbstractGameScreen.SCREEN_WIDTH >> 1;
	private final int WIDTH_SCREEN_3_1 = AbstractGameScreen.SCREEN_WIDTH / 3;
	private final int WIDTH_SCREEN_3_2 = WIDTH_SCREEN_3_1 * 2;
	private final int WIDTH_SCREEN_4_1 = AbstractGameScreen.SCREEN_WIDTH >> 2;
//	private final int WIDTH_SCREEN_4_3 = WIDTH_SCREEN_4_1 * 3;
//	private final int X_BG = 15;
	private final int Y_BG = 20;
//	private final int WIDTH_BG = AbstractGameScreen.SCREEN_WIDTH - (X_BG << 1);
	private final int HEIGHT_BG = AbstractGameScreen.SCREEN_HEIGHT - (Y_BG << 1);
//	private final int X_MSG = X_BG + 20;
//	private final int Y_MSG = Y_PASSWORD + AbstractGameScreen.FONT_H * 3 + 50;
//	private final int WIDTH_MSG = WIDTH_BG - 40;
//	private final int HEIGHT_MSG = Y_BG + HEIGHT_BG - Y_MSG - 10;
//	private int WIDTH_ACTOR_BG = 0;
//	private int HEIGHT_ACTOR_BG = 0;
//	private int X_ACTOR_BG = 0;
	private final int Y_ACTOR_BG = Y_BG + 50;
	private int X_ACTOR_MSG = 0;
	private int Y_ACTOR_MSG = 0;
	private int WIDTH_ACTOR_MSG = 0;
	private int HEIGHT_ACTOR_MSG = 0;
//	private final int STRING_WIDTH_4 = AbstractGameScreen.s_font.stringWidth("登录游戏");
//	private final int STRING_WIDTH_7 = AbstractGameScreen.s_font.stringWidth("保存用户名密码");
//	private final int STRING_WIDTH_DLYX = STRING_WIDTH_4 + 40;
//	private final int[][] LOGIN_BOX_PROPERTY = {
//			{ X_NAME, Y_NAME, WIDTH_SCREEN_2_1, AbstractGameScreen.FONT_H + 4 }, //账号
//			{ X_NAME, Y_PASSWORD, WIDTH_SCREEN_2_1, AbstractGameScreen.FONT_H + 4 },// 密码
//			{ WIDTH_SCREEN_2_1 - ((STRING_WIDTH_7 + 10) >> 1) - 15, Y_PASSWORD + AbstractGameScreen.FONT_H + 10,
//					STRING_WIDTH_7 + 10, AbstractGameScreen.FONT_H },// 记住账号及密码
//			{ (WIDTH_SCREEN_2_1 - STRING_WIDTH_DLYX) >> 1,
//					Y_PASSWORD + AbstractGameScreen.FONT_H * 2 + 25,
//					STRING_WIDTH_DLYX, AbstractGameScreen.FONT_H },// 登录游戏
//
//			{ ((WIDTH_SCREEN_2_1 - STRING_WIDTH_DLYX) >> 1) + WIDTH_SCREEN_2_1,
//					Y_PASSWORD + AbstractGameScreen.FONT_H * 2 + 45,
//					STRING_WIDTH_DLYX, AbstractGameScreen.FONT_H },// 账号注册
//			{ (WIDTH_SCREEN_2_1 - STRING_WIDTH_DLYX) >> 1,
//					Y_PASSWORD + AbstractGameScreen.FONT_H * 3 + 45,
//					STRING_WIDTH_DLYX, AbstractGameScreen.FONT_H },// 账号管理
//			{ ((WIDTH_SCREEN_2_1 - STRING_WIDTH_DLYX) >> 1) + WIDTH_SCREEN_2_1,
//					Y_PASSWORD + AbstractGameScreen.FONT_H * 3 + 45,
//					STRING_WIDTH_DLYX, AbstractGameScreen.FONT_H },// 游戏设置
//		    { ((WIDTH_SCREEN_2_1 - STRING_WIDTH_DLYX) >> 1) + WIDTH_SCREEN_2_1,
//					Y_PASSWORD + AbstractGameScreen.FONT_H * 3 + 45,
//					STRING_WIDTH_DLYX, AbstractGameScreen.FONT_H },};// 游戏帮助

//	private final int[] LOGIN_BOX_WORD = { WORD_INDEX_ZH, WORD_INDEX_MM, WORD_INDEX_JZZHJMM, WORD_INDEX_DLYX,
//			WORD_INDEX_ZHZC, WORD_INDEX_ZHGL, WORD_INDEX_YXSZ, WORD_INDEX_YXBZ };
	private final String HELP_WORD = "客服联系方式：" + Tools.CHANGE_ROW + "可在游戏内按左下边\"社\"--服务--联系客服，与客服进行邮件沟通。" +
			Tools.CHANGE_ROW + "客服会在24小时内，通过客服邮件回答您的问题。" +
			Tools.CHANGE_ROW + "邮箱：gm@handinfo.cn" + Tools.CHANGE_ROW + "免费客服电话：4000611230"+Tools.CHANGE_ROW+"官网：3gmax.cn";
	private final String REPAIR_WORD = "是否确定修复游戏?";
	private final byte LOGIN_INDEX_ZH = 0;
	private final byte LOGIN_INDEX_MM = 1;
	private final byte LOGIN_INDEX_JZZHJMM = 2;
	private final byte LOGIN_INDEX_DLYX = 3;
	private final byte LOGIN_INDEX_ZHZC = 4;
	private final byte LOGIN_INDEX_ZHGL = 5;
	private final byte LOGIN_INDEX_YXSZ = 6;
	private final byte LOGIN_INDEX_YXBZ = 7;

	private byte[][] m_login_select_list = {
			{LOGIN_INDEX_YXBZ, LOGIN_INDEX_MM, LOGIN_INDEX_YXBZ, LOGIN_INDEX_MM},//账号
			{LOGIN_INDEX_ZH, LOGIN_INDEX_JZZHJMM, LOGIN_INDEX_ZH, LOGIN_INDEX_JZZHJMM},//密码
			{LOGIN_INDEX_MM, LOGIN_INDEX_DLYX, LOGIN_INDEX_MM, LOGIN_INDEX_DLYX},//保存
			{LOGIN_INDEX_JZZHJMM, LOGIN_INDEX_ZHZC, LOGIN_INDEX_JZZHJMM, LOGIN_INDEX_ZHZC},//登录
			{LOGIN_INDEX_DLYX, LOGIN_INDEX_YXSZ, LOGIN_INDEX_ZHGL, LOGIN_INDEX_ZHGL},//注册
			{LOGIN_INDEX_DLYX, LOGIN_INDEX_YXBZ, LOGIN_INDEX_ZHZC, LOGIN_INDEX_ZHZC},//管理
			{LOGIN_INDEX_ZHZC, LOGIN_INDEX_ZH, LOGIN_INDEX_YXBZ, LOGIN_INDEX_YXBZ},//设置
			{LOGIN_INDEX_ZHGL, LOGIN_INDEX_ZH, LOGIN_INDEX_YXSZ, LOGIN_INDEX_YXSZ},//帮助
	};

//	private int getStringWidth(String string)
//	{
//		return AbstractGameScreen.s_font.stringWidth(string);
//	}

	// //////////////////////////////////////////////////////////////
	// 服务器列表界面
	// //////////////////////////////////////////////////////////////
	/** 服务器列表 */
	public ArrayList m_server_list = new ArrayList();
	/** 服务器列表长度 */
	// public byte m_server_amount = 0;
	public long m_server_session = 0;// 会话标识
	/** 服务器选择下标 */
	private byte m_server_select = 0;
	private byte m_server_page = 0;

	private final int COLOR_SIDE1 = Tools.BLACK;// 外边
	private final int COLOR_SIDE2 = 0xd0D08C;// 中边
	private final int COLOR_SIDE3 = 0x0c3236;// 内边
	private final int COLOR_WORD1 = 0xf8ec89;// 没被选中的字
	private final int COLOR_WORD2 = Tools.WHITE;// 被选中的字
//	private final int COLOR_BOX1 = 0x1e4f54;// 单号框
//	private final int COLOR_BOX2 = 0x0c3236;// 双号框
//	private final int COLOR_BOX3 = 0x719170;// 选中的框


	private final int W_SERVER_BOX_AMOUNT = AbstractGameScreen.SCREEN_WIDTH - 35;
	private final int H_SERVER_BOX_AMOUNT = AbstractGameScreen.SCREEN_HEIGHT - 23 - (UITools.H_BUTTON << 1) - (UITools.GAP_EACH_LINE << 1);
	private final int AMOUNT_SERVER_BOX = H_SERVER_BOX_AMOUNT / UITools.H_SINGLE_BAR;
	private final int SERVER_BOX_H = AMOUNT_SERVER_BOX * UITools.H_SINGLE_BAR + (UITools.GAP_EACH_LINE << 1);
	private final int X_SERVER_BOX_AMOUNT = 10;
	private final int Y_SERVER_BOX_AMOUNT = 23 + UITools.H_BUTTON;

	private final int W_SERVER_BOX_GAP = 1;
	private final int W_SERVER_BOX_SERVER = W_SERVER_BOX_AMOUNT / 5 * 3 - (W_SERVER_BOX_GAP << 1);
	private final int W_SERVER_BOX_ROLE = W_SERVER_BOX_AMOUNT / 5;
	private final int W_SERVER_BOX_STATUS = W_SERVER_BOX_AMOUNT / 5;

	private final int X_SERVER_BOX_SERVER = X_SERVER_BOX_AMOUNT;
	private final int X_SERVER_BOX_ROLE = X_SERVER_BOX_AMOUNT + W_SERVER_BOX_SERVER + W_SERVER_BOX_GAP;
	private final int X_SERVER_BOX_STATUS = X_SERVER_BOX_ROLE + W_SERVER_BOX_ROLE + W_SERVER_BOX_GAP;

//	private final int AMOUNT_SERVER_BOX_H = H_SERVER_BOX_AMOUNT / AbstractGameScreen.FONT_H + 1;
	// //////////////////////////////////////////////////////////////
	// 快速注册界面
	// //////////////////////////////////////////////////////////////
//	private byte m_quick_select = 0;// 选择下标
//
//	private final int QUICK_REC_NAME_BOX_X = AbstractGameScreen.s_font.stringWidth("确认密码:  ") + 10;
//	private final int QUICK_REC_NAME_BOX_Y = AbstractGameScreen.SCREEN_HEIGHT >> 2;
//	private final int QUICK_REC_NAME_BOX_W = AbstractGameScreen.SCREEN_WIDTH / 5 * 3;
//	private final int QUICK_REC_NAME_BOX_H = AbstractGameScreen.FONT_H + 2;
//
//	private final int QUICK_REC_PW_BOX_X = QUICK_REC_NAME_BOX_X;
//	private final int QUICK_REC_PW_BOX_Y = QUICK_REC_NAME_BOX_Y + QUICK_REC_NAME_BOX_H + 10;
//	private final int QUICK_REC_PW_BOX_W = QUICK_REC_NAME_BOX_W;
//	private final int QUICK_REC_PW_BOX_H = QUICK_REC_NAME_BOX_H;
//
//	private final int QUICK_OPT_NAME_BOX_X = QUICK_REC_NAME_BOX_X;
//	private final int QUICK_OPT_NAME_BOX_Y = (AbstractGameScreen.SCREEN_HEIGHT >> 1) + 10;
//	private final int QUICK_OPT_NAME_BOX_W = QUICK_REC_NAME_BOX_W;
//	private final int QUICK_OPT_NAME_BOX_H = QUICK_REC_NAME_BOX_H;
//
//	private final int QUICK_OPT_PW_BOX_X = QUICK_REC_NAME_BOX_X;
//	private final int QUICK_OPT_PW_BOX_Y = QUICK_OPT_NAME_BOX_Y + QUICK_OPT_NAME_BOX_H + 10;
//	private final int QUICK_OPT_PW_BOX_W = QUICK_REC_NAME_BOX_W;
//	private final int QUICK_OPT_PW_BOX_H = QUICK_REC_NAME_BOX_H;
//
//	private final int QUICK_OPT_CON_BOX_X = QUICK_REC_NAME_BOX_X;
//	private final int QUICK_OPT_CON_BOX_Y = QUICK_OPT_PW_BOX_Y + QUICK_OPT_PW_BOX_H + 10;
//	private final int QUICK_OPT_CON_BOX_W = QUICK_REC_NAME_BOX_W;
//	private final int QUICK_OPT_CON_BOX_H = QUICK_REC_NAME_BOX_H;
//
//	private final int QUICK_REC_BOX_PLAY_X = 20;// 推荐进入游戏框
//	private final int QUICK_REC_BOX_PLAY_Y = QUICK_REC_PW_BOX_Y + QUICK_REC_PW_BOX_H + 10;
//	private final int QUICK_REC_BOX_PLAY_W = AbstractGameScreen.SCREEN_WIDTH - (QUICK_REC_BOX_PLAY_X << 1);
//	private final int QUICK_REC_BOX_PLAY_H = QUICK_OPT_CON_BOX_H;
//
//	private final int QUICK_OPT_BOX_PLAY_X = QUICK_REC_BOX_PLAY_X;// 自添进入游戏框
//	private final int QUICK_OPT_BOX_PLAY_Y = QUICK_OPT_CON_BOX_Y + QUICK_OPT_CON_BOX_H + 10;
//	private final int QUICK_OPT_BOX_PLAY_W = QUICK_REC_BOX_PLAY_W;
//	private final int QUICK_OPT_BOX_PLAY_H = QUICK_OPT_CON_BOX_H;

//	private final int[][] QUICK_BOX_PROPERTY = {
//			{ QUICK_REC_NAME_BOX_X, QUICK_REC_NAME_BOX_Y, QUICK_REC_NAME_BOX_W,
//					QUICK_REC_NAME_BOX_H },
//			{ QUICK_REC_PW_BOX_X, QUICK_REC_PW_BOX_Y, QUICK_REC_PW_BOX_W,
//					QUICK_REC_PW_BOX_H },
//			{ QUICK_REC_BOX_PLAY_X, QUICK_REC_BOX_PLAY_Y, QUICK_REC_BOX_PLAY_W,
//					QUICK_REC_BOX_PLAY_H },
//			{ QUICK_OPT_NAME_BOX_X, QUICK_OPT_NAME_BOX_Y, QUICK_OPT_NAME_BOX_W,
//					QUICK_OPT_NAME_BOX_H },
//			{ QUICK_OPT_PW_BOX_X, QUICK_OPT_PW_BOX_Y, QUICK_OPT_PW_BOX_W,
//					QUICK_OPT_PW_BOX_H },
//			{ QUICK_OPT_CON_BOX_X, QUICK_OPT_CON_BOX_Y, QUICK_OPT_CON_BOX_W,
//					QUICK_OPT_CON_BOX_H },
//			{ QUICK_OPT_BOX_PLAY_X, QUICK_OPT_BOX_PLAY_Y, QUICK_OPT_BOX_PLAY_W,
//					QUICK_OPT_BOX_PLAY_H } };
//	private final String[] QUICK_BOX_CHARS = { "账号：", "密码：", "账号：", "密码：", "确认密码：" };
//	private String[] m_quick_box_content = { "11111", "22222", "33333", "44444", "44444" };
	// //////////////////////////////////////////////////////////////
	// 输入法部分 (只支持数字和字母)
	// //////////////////////////////////////////////////////////////
//	private ArrayList m_input_list = new ArrayList();// 已输入的字符
//	private String m_input_chars = "";// 已经输入的字符串
//	private String[][] INPUT_METHOD = // 输入法数组
//	{	{ "0" },
//		{ "1" },
//		{ "2", "a", "b", "c", "A", "B", "C" },
//		{ "3", "d", "e", "f", "D", "E", "F" },
//		{ "4", "g", "h", "i", "G", "H", "I" },
//		{ "5", "j", "k", "l", "J", "K", "L" },
//		{ "6", "m", "n", "o", "M", "N", "O" },
//		{ "7", "p", "q", "r", "s", "P", "Q", "R", "S" },
//		{ "8", "t", "u", "v", "T", "U", "V" },
//		{ "9", "w", "x", "y", "z", "W", "X", "Y", "Z" } };
//	private byte m_input_col = 0;// 当前列数
//	private byte m_input_row = -1;// 当前行数
	private int m_timer = 0;// 计时器

//	private void drawInputChars(Graphics g, int x, int y, int color)
//	{
//		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH,
//				AbstractGameScreen.SCREEN_HEIGHT);
//		if (m_input_chars != null) {
//			g.setColor(color);
//			g.drawString(m_input_chars, x, y, Tools.LEFT_TOP);
//		}
//		if (m_input_row > -1) {
//			String temp = INPUT_METHOD[m_input_row][m_input_col];
//			if (m_timer % 8 > 3) {
//				g.setColor(Tools.GREEN);
//				if (m_input_chars != null) {
//					g.fillRect(x + AbstractGameScreen.s_font.stringWidth(m_input_chars) + 1, y,
//							AbstractGameScreen.s_font.stringWidth("C"),
//							AbstractGameScreen.FONT_H);
//				}
//				else {
//					g.fillRect(x, y,
//							AbstractGameScreen.s_font.stringWidth("C"),
//							AbstractGameScreen.FONT_H);
//				}
//			}
//			g.setColor(Tools.BLACK);
//			if (m_input_chars != null) {
//				g.drawString(
//						temp,
//						x + AbstractGameScreen.s_font.stringWidth(m_input_chars) + 1, y,
//						Tools.LEFT_TOP);
//			}
//			else {
//				g.drawString(temp, x, y, Tools.LEFT_TOP);
//			}
//		}
//		else {
//			if (m_timer % 8 > 3) {
//				g.setColor(Tools.BLACK);
//				if (m_input_chars != null) {
//					g.fillRect(
//							x
//									+ AbstractGameScreen.s_font
//											.stringWidth(m_input_chars) + 1, y,
//							2, AbstractGameScreen.FONT_H);
//				}
//				else {
//					g.fillRect(x, y, 2, AbstractGameScreen.FONT_H);
//				}
//			}
//		}
//	}

//	private void inputMethodKeyPressed()
//	{// 输入法按键方法
//		byte key = -1;
//		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY0)) {
//			key = 0;
//		}
//		else if (AbstractGameScreen
//				.haveKeyPressed(AbstractGameScreen.GK_KEY1)) {
//			key = 1;
//		}
//		else if (AbstractGameScreen
//				.haveKeyPressed(AbstractGameScreen.GK_KEY2)) {
//			key = 2;
//		}
//		else if (AbstractGameScreen
//				.haveKeyPressed(AbstractGameScreen.GK_KEY3)) {
//			key = 3;
//		}
//		else if (AbstractGameScreen
//				.haveKeyPressed(AbstractGameScreen.GK_KEY4)) {
//			key = 4;
//		}
//		else if (AbstractGameScreen
//				.haveKeyPressed(AbstractGameScreen.GK_KEY5)) {
//			key = 5;
//		}
//		else if (AbstractGameScreen
//				.haveKeyPressed(AbstractGameScreen.GK_KEY6)) {
//			key = 6;
//		}
//		else if (AbstractGameScreen
//				.haveKeyPressed(AbstractGameScreen.GK_KEY7)) {
//			key = 7;
//		}
//		else if (AbstractGameScreen
//				.haveKeyPressed(AbstractGameScreen.GK_KEY8)) {
//			key = 8;
//		}
//		else if (AbstractGameScreen
//				.haveKeyPressed(AbstractGameScreen.GK_KEY9)) {
//			key = 9;
//		}
//		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_D)) {// "*"
//			key = 10;
//		}
//		else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_B)) {// "#"
//			key = 11;
//		}
//		if (key > -1 && key < 10) {
//			if (m_input_row == key) {
//				m_input_col = ++m_input_col == INPUT_METHOD[m_input_row].length ? 0
//						: m_input_col;
//			}
//			else {
//				m_input_row = key;
//				m_input_col = 0;
//			}
//		}
//		else if (key == 10) {
//			if (m_input_row == -1) {
//				if (m_input_list.size() > 0) {
//					m_input_chars = "";
//					m_input_list.removeElementAt(m_input_list.size() - 1);
//				}
//			}
//			else {
//				m_input_row = -1;
//			}
//		}
//		else if (key == 11) {
//			if (m_input_row > -1) {
//				m_input_list.addElement(INPUT_METHOD[m_input_row][m_input_col]);
//				m_input_row = -1;
//			}
//		}
//		if (m_input_list.size() > 0) {
//			m_input_chars = "";
//			for (int i = 0; i < m_input_list.size(); i++) {
//				m_input_chars += m_input_list.elementAt(i).toString();
//			}
//		}
//	}
//
//	private void addInputChars(String chars)
//	{
//		if (chars != null && chars.length() > 0) {
//			m_input_chars = chars;
//			for (int i = 0; i < chars.length(); i++) {
//				m_input_list.addElement(chars.substring(i, i + 1));
//			}
//		}
//	}
//
//	private void clearInput()
//	{
//		m_input_row = -1;
//		m_input_chars = "";
//		m_input_list.removeAllElements();
//	}

	public synchronized void dispose()
	{
//		if (img_user != null) {
//			for (int i = 0; i < img_user.length; i++) {
//				img_user[i] = null;
//			}
//			img_user = null;
//		}
		img_lianhua = null;
		img_select = null;
		img_choose_bg = null;
		img_choose_cn = null;
		img_background = null;
		img_background_logo = null;

		if (img_word_list != null) {
			for (int i = 0; i < img_word_list.length; i++) {
				img_word_list[i] = null;
			}
			img_word_list = null;
		}

		img_small_star = null;
		img_big_star = null;

		img_sex = null;
		img_job = null;
		img_race = null;
		img_cursor_corner = null;
		img_cursor_side = null;

		img_bar_big = null;
		img_bar_small = null;

		if (m_role_list != null) {
			for (int i = 0; i < m_role_list.length; i++) {
				if (m_role_list[i] != null) {
					m_role_list[i].destroy();
					m_role_list[i] = null;
				}
			}
			m_role_list = null;
		}
		if (m_create_role != null) {
			m_create_role.destroy();
			m_create_role = null;
		}
		if (m_anim_flower != null) {
			m_anim_flower.destroy();
			m_anim_flower = null;
		}
		if (m_user_resource != null) {
			m_user_resource.removeAll();
			m_user_resource = null;
		}
	}


}

class Star
{
	public Star()
	{
		m_x = Tools.getRandom(0, AbstractGameScreen.SCREEN_WIDTH);
		m_type = Tools.getRandom(0, 100) > 49 ? TYPE_BIG : TYPE_SMALL;
		m_speed_x = (short) Tools.getRandom(SPEED_X_MIN, SPEED_X_MAX);
		m_over_y = Tools.getRandom(AbstractGameScreen.SCREEN_HEIGHT >> 1,
				AbstractGameScreen.SCREEN_HEIGHT);
		refreshStar();
	}

	public void drawStar(Graphics g, Image img)
	{
		g.drawImage(img, m_x, m_y, Tools.HCENTER_VCENTER);
	}

	private void refreshStar()
	{
		// m_dir = (byte)Tools.getRandom(DIR_LEFT, DIR_RIGHT);
		m_speed_y = (short) Tools.getRandom(SPEED_Y_MIN, SPEED_Y_MAX);
		m_continue = (byte) Tools.getRandom(CONTINUE_MIN, CONTINUE_MAX);
		m_dir = m_dir == DIR_LEFT ? DIR_RIGHT : DIR_LEFT;
	}

	private byte time = 0;

	public boolean logic()
	{
		if (m_continue < 0) {
			switch (m_dir) {
				case DIR_LEFT:
					m_y += 1;
					break;
				case DIR_RIGHT:
					m_y += 1;
					break;
			}
			if (time++ == 3) {
				time = 0;
				refreshStar();
			}
		}
		else {
			byte speedX = (byte) (m_speed_x / MULTIPLE_SPEED_X);
			byte speedY = (byte) (m_speed_y / MULTIPLE_SPEED_Y);
			m_x_move_amount++;
			m_y_move_amount++;
			switch (m_dir) {
				case DIR_LEFT:
					m_x -= speedX;
					m_y += speedY;
					break;
				case DIR_RIGHT:
					m_x += speedX;
					m_y += speedY;
					break;
			}
			if (m_y > m_over_y) {
				return true;
			}
		}
		m_continue--;
		return false;
	}


	private int m_x = 0;
	private int m_y = 0;

	private byte m_dir = 0;// 方向
	private short m_speed_x = 0;// x速度
	private short m_speed_y = 0;// y速度
	private byte m_continue = 0;// 该方向持续时间
	public byte m_type = 0;// 星星种类
	private int m_over_y = 0;// 消失的坐标
	private int m_x_move_amount = 0;// x移动次数
	private int m_y_move_amount = 0;// y移动次数

	private final byte MULTIPLE_SPEED_X = 100;// x速度放大倍数
	private final byte MULTIPLE_SPEED_Y = 100;// y速度放大倍数

	private final byte DIR_LEFT = 0;// 左
	private final byte DIR_RIGHT = 1;// 右

	private final short SPEED_X_MIN = 100;// x最小速度
	private final short SPEED_X_MAX = 200;// x最大速度

	private final short SPEED_Y_MIN = 100;// y最小速度
	private final short SPEED_Y_MAX = 100;// y最大速度

	private final byte CONTINUE_MIN = 10;// 最小持续时间
	private final byte CONTINUE_MAX = 50;// 最大持续时间

	public final byte TYPE_SMALL = 0;// 小星星
	public final byte TYPE_BIG = 1;// 大星星

}
